Received: from mail.austin.rr.com (sm1.texas.rr.com [24.93.35.54]) by hub.org (8.10.1/8.10.1) with ESMTP id e5QGqP109838 for ; Mon, 26 Jun 2000 12:52:25 -0400 (EDT) Received: from austin.rr.com ([24.93.36.87]) by mail.austin.rr.com with Microsoft SMTPSVC(5.5.1877.357.35); Mon, 26 Jun 2000 11:53:43 -0500 Message-ID: <39578B61.CDAF7D91@austin.rr.com> Date: Mon, 26 Jun 2000 11:57:05 -0500 From: Ed Loehr X-Mailer: Mozilla 4.7 [en] (X11; U; Linux 2.2.12-20smp i686) X-Accept-Language: en MIME-Version: 1.0 To: Bryan White CC: pgsql-sql Subject: Re: A subselect in an aggregate References: <000b01bfdf8c$aef88000$2dd260d1@arcamax.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200006/228 Bryan White wrote: > > This statement works: > select date, (select sum(qty * price) from orderdetail d where d.orderid = > orders.orderid) from orders > > But when I try to do something like this: > > select date, sum(select sum(qty * price) from orderdetail d where d.orderid > = orders.orderid) from orders group by date > > I get ERROR: parser: parse error at or near "select" > > Is there a way to apply an agregate function to a subselect like this? Avoiding the question, I'm wondering if this simpler form wouldn't be what you're after? select o.date, sum(d.qty * d.price) from orderdetail d, orders o where d.orderid = o.orderid group by o.date Regards, Ed Loehr