- SELECT t1.country,
- t1.total_invoice,
- t2.total_customer
- FROM
- (SELECT billing_country AS country,
- COUNT (invoice_id) AS total_invoice
- FROM invoice
- WHERE EXTRACT(YEAR FROM CAST(invoice_date AS date)) =
- (
- SELECT EXTRACT(YEAR FROM CAST(invoice_date AS date))
- FROM invoice
- GROUP BY EXTRACT(YEAR FROM CAST(invoice_date AS date))
- ORDER BY SUM(total) DESC
- LIMIT 1)
- GROUP BY country) AS t1
- LEFT JOIN
- (SELECT billing_country AS country,
- COUNT (customer_id) AS total_customer
- FROM invoice
- GROUP BY country) AS t2 ON t1.country=t2.country
- ORDER BY t1.total_invoice DESC, t1.country;
Re: Untitled
From Thundering Sheep, 4 Months ago, written in Plain Text, viewed 61 times.
This paste is a reply to Untitled from Eratic Tern
- view diff
URL http://codebin.org/view/df8684ee
Embed
Download Paste or View Raw
— Expand Paste to full width of browser