- SELECT *
- FROM
- (SELECT count(total) as year_2011,
- EXTRACT(month from CAST(invoice_date AS timestamp)) as month
- FROM invoice
- where EXTRACT(YEAR FROM CAST(invoice_date AS timestamp))=2011
- GROUP BY month) as year2011
- FULL JOIN
- (SELECT count(total) as year_2012
- EXTRACT(month from CAST(invoice_date AS timestamp)) as month
- FROM invoice
- where EXTRACT(YEAR FROM CAST(invoice_date AS timestamp))=2012
- GROUP BY month) as year2012 ON year2011.month=year2012.month