Re: [SQL] subquery, except and view

From: marten(at)feki(dot)toppoint(dot)de
To: Max(dot)Buvry(at)enseeiht(dot)fr (Max Buvry)
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] subquery, except and view
Date: 1999-12-09 08:08:24
Message-ID: 199912090808.JAA03583@feki.toppoint.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>
> I don't understand why the two queries below
> are not correct with Postgresql though it be correct with Oracle
> (I want to know the clients which have not
> made more than 2 commands) :
>
> -------
> QUERY 1
> -------
>
> select clt.num_clt
> from client clt
> where clt.num_clt not in
> (select cd.num_clt
> from commande cd
> group by cd.num_clt
> having count(*) > 2);
>
> The PostgreSQL Error is : rewrite: aggregate column
> view must be at rigth side in qual
>
> I test the subquery and it is ok.
>

More or less this question is asked again and again - I've asked
this before - perhaps 3-4 weeks ago - it should be put into a faq.

It's a restriction of PostgreSQL and it's SQL parser. The
aggregate column is count(*) and it "could" work perhaps if
you rewrite it as ".... 2 <= count(*)".

It was said on this list, that the rewriter might interpret the
statement not correctly and return wrong results.

You should have a closer look at the archive with subjects like
having, group ... (last 8 weeks).

Marten

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message tjk@tksoft.com 1999-12-09 08:57:00 Re: [SQL] select a part of a name
Previous Message neko 1999-12-09 02:36:39 Re: [SQL] select a part of a name