A subselect in an aggregate

From: "Bryan White" <bryan(at)arcamax(dot)com>
To: "pgsql-sql" <pgsql-sql(at)postgreSQL(dot)org>
Subject: A subselect in an aggregate
Date: 2000-06-26 16:36:31
Message-ID: 000b01bfdf8c$aef88000$2dd260d1@arcamax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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?

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ed Loehr 2000-06-26 16:57:05 Re: A subselect in an aggregate
Previous Message Kyle Bateman 2000-06-26 15:35:48 finding (and recycling) holes in sequences