Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
473 B
3
Indexable
SELECT billing_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)) AS year 
                FROM invoice AS i
                WHERE EXTRACT(month FROM CAST(invoice_date AS date)) IN (6, 7, 8)
                GROUP BY year
                 ORDER BY SUM(total) DESC
                 LIMIT 1)
          GROUP BY billing_country