Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. SELECT a.transaction_week,
  2. SUM(CASE WHEN record_type IN (6,37,13) THEN quantity ELSE 0 END) as SalesVol
  3. FROM table 1 a
  4. LEFT JOIN table 2 b ON b.Date = a.transaction_date
  5. LEFT JOIN table 3 c ON c.sku = a.product
  6. WHERE series in (62,236,501,52)
  7. GROUP BY a.transaction_week
  8. ORDER BY a.transaction_week
  9.  
  10. SELECT a.transaction_week,
  11.  
  12. (SELECT SUM(CASE WHEN record_type IN (6,37,13) THEN quantity ELSE 0 END) as SalesVol
  13. FROM table 1 a
  14. LEFT JOIN table 2 b ON b.Date = a.transaction_date
  15. LEFT JOIN table 3 c ON c.sku = a.product
  16. WHERE series in (62,236,501,52)) as personal care
  17.  
  18. (SELECT SUM(CASE WHEN record_type IN (6,37,13) THEN quantity ELSE 0 END) as SalesVol
  19. FROM table 1 a
  20. LEFT JOIN table 2 b ON b.Date = a.transaction_date
  21. LEFT JOIN table 3 c ON c.sku = a.product
  22. WHERE series in (37,202,203,456)) as white goods
  23.  
  24. FROM table 1 a
  25. LEFT JOIN table 2 b ON b.Date = a.transaction_date
  26. LEFT JOIN table 3 c ON c.sku = a.product
  27. GROUP BY a.transaction_week
  28. ORDER BY a.transaction_week
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement