daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest May 19th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT b.full_name,
  2.   SUM((SELECT price FROM prices p WHERE p.date < a.date AND p.PRODUCT_ID = a.PRODUCT_ID ORDER BY date DESC LIMIT 1) * a.quantity) AS TOTAL
  3. FROM
  4.   historysales a
  5.   INNER JOIN customer_w b ON (a.customer_id = b.customer_id)
  6. WHERE
  7.   `date` BETWEEN ('2006-01-01') AND ('2008-01-01')
  8. GROUP BY b.full_name,DATE_FORMAT(a.`date`, '%b-%Y')
  9. order by date
RAW Paste Data
Top