pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: marten@feki.toppoint.de
To: Max.Buvry@enseeiht.fr
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] subquery, except and view
Date: Thu, 9 Dec 1999 09:08:24 +0100 (CET)
Message-ID: <199912090808.JAA03583@feki.toppoint.de> (raw)
In-Reply-To: <199912071443.PAA11193@enseeiht.enseeiht.fr>

> 
> 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





view thread (5+ messages)  latest in thread

Message-ID: <199912090808.JAA03583@feki.toppoint.de>
Permalink:  ../199912090808.JAA03583@feki.toppoint.de/
Also on:    postgresql.org/message-id/199912090808.JAA03583@feki.toppoint.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: marten@feki.toppoint.de, Max.Buvry@enseeiht.fr
  Subject: Re: [SQL] subquery, except and view
  In-Reply-To: <199912090808.JAA03583@feki.toppoint.de>
  References: <199912071443.PAA11193@enseeiht.enseeiht.fr> <199912090808.JAA03583@feki.toppoint.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox