SELECT num_ads, sum(...), sum(...), ....
FROM ( your query here )
GROUP BY num_ads;
BTW, While "SELECT '1' "num_ads" is valid syntax I recommend you use the
"AS" keyword. '1' AS "num_ads"
David J.
--
View this message in context: http://postgresql.1045698.n5.nabble.com/pivot-query-with-count-tp5752072p5752077.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.