Re: Untitled

From Idiotic Leech, 6 Months ago, written in Plain Text, viewed 88 times. This paste is a reply to Untitled from Eratic Tern - go back
URL http://codebin.org/view/f5876218/diff Embed
Viewing differences between Untitled and Re: Untitled
SELECT customer_id,
       invoice_date, EXTRACT (WEEK 
t1.country,
       t1.total_invoice,
       t2.total_customer
FROM
(SELECT billing_country AS country,
        COUNT (invoice_id) AS total_invoice
FROM invoice_date::date),
       total
invoice
WHERE EXTRACT(YEAR 
FROM invoice;

CAST(invoice_date AS date)) = 
(
SELECT customer_id,
       invoice_date, EXTRACT (WEEK 
EXTRACT(YEAR FROM cast(invoice_date as date)),
       total
CAST(invoice_date AS date))
FROM invoice;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;

Reply to "Re: Untitled"

Here you can reply to the paste above