Skip site navigation (1) Skip section navigation (2)

Complex query

From: "J(dot) Fernando Moyano" <txinete(at)wanadoo(dot)es>
To: pgsql-sql(at)hub(dot)org
Subject: Complex query
Date: 2000-08-27 23:42:03
Message-ID: 00082801521705.00923@txino.mikasa.eh (view raw or flat)
Thread:
Lists: pgsql-sql

Hey everybody !!!
I am new on this list !!!

I have a little problem .....

I try this on my system:

"select n_lote from pedidos except select rp.n_lote from relpedidos rp,
relfacturas rf where  rp.n_lote=rf.n_lote group by rp.n_lote having
sum(rp.cantidad)=sum(rf.cantidad)"

I get this result:
 
ERROR: rewrite: comparision of 2 aggregate
columns not supported 

but if a try this one:

"select rp.n_lote from relpedidos rp, relfacturas rf where 
rp.n_lote=rf.n_lote group by rp.n_lote having sum(rp.cantidad)=sum(rf.cantidad)"

It's OK !!

What's up???
Do you think i found a bug  ???
Do exist some limitation like this in subqueries??

(Perhaps Postgres don't accept using aggregates in subqueries ???)

I tried this too:

"select n_lote from pedidos where n_lote not in (select rp.n_lote from
relpedidos rp, relfacturas rf where  rp.n_lote=rf.n_lote group by rp.n_lote
having sum(rp.cantidad)=sum(rf.cantidad))"

but the result was the same !

And i get the same error message (or similar) when i try other variations.

Thanks !!!

Fer

-- 
  ************* ******   ******  **********  *****   *****    *******
 *************   ***** ******   **********  ******  *****  ***********
    *****         ********        ****     *************  ****    ****
   *****           ****          ****     ***** *******  ****    ****
  *****          *******        ****     *****  ******  ****    ****
 *****        ****** *****   *********  *****   *****  ************
*****       ******   ****** *********  *****   *****    ******** 

 (*) SymeX ==> http://www.lantik.com
 (*) Web en http://www.arrakis.es/~txino      
 (*) Informate sobre LINUX en http://www.linux.org

pgsql-sql by date

Next:From: Yury DonDate: 2000-08-28 03:49:00
Subject: Re: weird structure
Previous:From: Mitch VincentDate: 2000-08-27 22:01:02
Subject: Re: queries and inserts

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group