Untitled

From Trivial Pheasant, 4 Days ago, written in Plain Text, viewed 9 times.
URL http://codebin.org/view/06acf79f Embed
Download Paste or View Raw
  1. SELECT wer.last_name
  2. FROM (SELECT i.customer_id, cl.last_name,
  3.        CAST(i.invoice_date AS date)
  4. FROM invoice as i
  5. LEFT JOIN client as cl on cl.customer_id= i.customer_id
  6. WHERE EXTRACT(MONTH FROM CAST(i.invoice_date AS date)) = 1 AND EXTRACT(YEAR FROM CAST(i.invoice_date AS date)) = 2013
  7. GROUP BY i.customer_id,CAST(i.invoice_date AS date),cl.last_name) as der
  8. LEFT OUTER JOIN
  9. (SELECT cl.last_name,cl.customer_id,CAST(i.invoice_date AS date)
  10. FROM client as cl
  11. LEFT JOIN invoice as i on i.customer_id=cl.customer_id
  12. WHERE EXTRACT(YEAR FROM CAST(i.invoice_date AS date)) = 2013 and EXTRACT(MONTH FROM CAST(i.invoice_date AS date)) <> 1
  13. GROUP BY cl.last_name,cl.customer_id,CAST(i.invoice_date AS date)) as wer on wer.customer_id = der.customer_id
  14. GROUP BY wer.last_name

Replies to Untitled rss

Title Name Language When
Re: Untitled Colossal Moth text 3 Days ago.

Reply to "Untitled"

Here you can reply to the paste above