All pastes #237060 Raw Edit

yegs

public text v1 · immutable
·published 2006-11-04 09:01 UTC
rendered paste body
i need to run 1 query that adds 2 queries together
select aid, sum(score) as stotal from songs group by aid;
select id, sum(score) as stotal from artists group by id;
this 2.. i need to add
i need a third query that would add result of both first queries.
how do i do that under 1 total query?

--

select id, sum(score) as stotal
from (select aid as id, score from songs
union select id, score from artists) r
group by id