I am trying to query the following:
select currency, sum(volume)
from
(
select "baseCurrency" as currency,
COALESCE("baseVolume", 0) as volume
from "Pairs"
) as a
union all
(
select "quoteCurrency" as currency,
COALESCE("quoteVolume", 0) as volume
from "Pairs"
) as b
group by currency
But keeps getting errors no matter how I changed the query. For example:
ERROR: syntax error at or near "as"
LINE 11: ) as b
What is wrong in this query?