Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT EXTRACT(MONTH FROM CAST(invoice_date AS DATE)) AS MONTH,
- COUNT(invoice_id) AS year_2011
- FROM invoice
- WHERE EXTRACT(YEAR FROM CAST(invoice_date AS DATE)) = 2011
- --OR EXTRACT(YEAR FROM CAST(invoice_date AS date)) = 2012
- --OR EXTRACT(YEAR FROM CAST(invoice_date AS date)) = 2013
- GROUP BY MONTH
- UNION ALL
- SELECT EXTRACT(MONTH FROM CAST(invoice_date AS DATE)) AS MONTH,
- COUNT(invoice_id) AS year_2012
- FROM invoice
- --WHERE EXTRACT(YEAR FROM CAST(invoice_date AS date)) = 2011
- WHERE EXTRACT(YEAR FROM CAST(invoice_date AS DATE)) = 2012
- --OR EXTRACT(YEAR FROM CAST(invoice_date AS date)) = 2013
- GROUP BY MONTH
- UNION ALL
- SELECT EXTRACT(MONTH FROM CAST(invoice_date AS DATE)) AS MONTH,
- COUNT(invoice_id) AS year_2013
- FROM invoice
- --WHERE EXTRACT(YEAR FROM CAST(invoice_date AS date)) = 2011
- --WHERE EXTRACT(YEAR FROM CAST(invoice_date AS date)) = 2012
- WHERE EXTRACT(YEAR FROM CAST(invoice_date AS DATE)) = 2013
- GROUP BY MONTH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement