Re: Untitled

From Idiotic Leech, 4 Months ago, written in Plain Text, viewed 67 times. This paste is a reply to Untitled from Eratic Tern - view diff
URL http://codebin.org/view/f5876218 Embed
Download Paste or View Raw
  1. SELECT t1.country,
  2.        t1.total_invoice,
  3.        t2.total_customer
  4. FROM
  5. (SELECT billing_country AS country,
  6.         COUNT (invoice_id) AS total_invoice
  7. FROM invoice
  8. WHERE EXTRACT(YEAR FROM CAST(invoice_date AS date)) =
  9. (
  10. SELECT EXTRACT(YEAR FROM CAST(invoice_date AS date))
  11. FROM invoice
  12. GROUP BY EXTRACT(YEAR FROM CAST(invoice_date AS date))
  13. ORDER BY SUM(total) DESC
  14. LIMIT 1)
  15. GROUP BY country) AS t1
  16.  
  17. LEFT JOIN
  18. (SELECT billing_country AS country,
  19.        COUNT (customer_id) AS total_customer
  20. FROM invoice
  21. GROUP BY country) AS t2 ON  t1.country=t2.country
  22. ORDER BY t1.total_invoice DESC, t1.country;

Reply to "Re: Untitled"

Here you can reply to the paste above