Re: Untitled

From Bulky Cheetah, 8 Months ago, written in Plain Text, viewed 267 times. This paste is a reply to Untitled from Sexy Baboon - view diff
URL http://codebin.org/view/fd238e8a Embed
Download Paste or View Raw
  1. WITH
  2. m12 AS (SELECT EXTRACT(MONTH FROM CAST(invoice_date AS timestamp)) AS month,
  3.      SUM(total) AS sum_total_2012
  4.      FROM invoice
  5.      WHERE EXTRACT(YEAR FROM CAST(invoice_date AS timestamp))=2012
  6.      GROUP BY month),
  7.      
  8. m13 AS (SELECT EXTRACT(MONTH FROM CAST(invoice_date AS timestamp)) AS month,
  9.      SUM(total) AS sum_total_2013
  10.      FROM invoice
  11.      WHERE EXTRACT(YEAR FROM CAST(invoice_date AS timestamp))=2013  
  12.      GROUP BY month)
  13. SELECT m12.month,
  14. sum_total_2012,
  15. sum_total_2013,
  16. ROUND(((m13.sum_total_2013 - m12.sum_total_2012)/m13.sum_total_2013)*100 ) as perc
  17. FROM m12 FULL JOIN m13 ON m12.month=m13.month
  18. ORDER BY month
  19.  
  20.  
  21.  

Reply to "Re: Untitled"

Here you can reply to the paste above