Louis-David Mitterrand <cunctator@apartia.ch> writes:
> Now I would like to sum() all results from the quantity column and
> return it with one SELECT statement. Is that possible?
You can't have aggregates of aggregates in a single SELECT structure;
that's just not in the SQL execution model. The way around this is
to write multiple levels of SELECT, using either selection from a
grouped/aggregated view or subselect-in-FROM. Unfortunately Postgres
doesn't have either of those features --- yet. They might be in 7.1
if I spend less time answering email and more time coding...
regards, tom lane