On 12/21/2013 10:30 AM, RSmith wrote:
Just move the scope of the grouping and use Nulls in stead of 0's, like
this:
SELECT stats.which_year AS year,
SUM(CASE WHEN stats.which_month = 1 THEN stats.quantity ELSE NULL END) AS
gen,
SUM(CASE WHEN stats.which_month = 2 THEN stats.quantity ELSE NULL END) AS
feb,
Or a bit more compact:
SELECT stats.which_year AS year,
SUM(stats.quantity * (stats.which_month = 1)) AS gen,
SUM(stats.quantity * (stats.which_month = 2)) AS feb,
...
--
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users