Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT a.transaction_week,
- SUM(CASE WHEN record_type IN (6,37,13) THEN quantity ELSE 0 END) as SalesVol
- FROM table 1 a
- LEFT JOIN table 2 b ON b.Date = a.transaction_date
- LEFT JOIN table 3 c ON c.sku = a.product
- WHERE series in (62,236,501,52)
- GROUP BY a.transaction_week
- ORDER BY a.transaction_week
- SELECT a.transaction_week,
- (SELECT SUM(CASE WHEN record_type IN (6,37,13) THEN quantity ELSE 0 END) as SalesVol
- FROM table 1 a
- LEFT JOIN table 2 b ON b.Date = a.transaction_date
- LEFT JOIN table 3 c ON c.sku = a.product
- WHERE series in (62,236,501,52)) as personal care
- (SELECT SUM(CASE WHEN record_type IN (6,37,13) THEN quantity ELSE 0 END) as SalesVol
- FROM table 1 a
- LEFT JOIN table 2 b ON b.Date = a.transaction_date
- LEFT JOIN table 3 c ON c.sku = a.product
- WHERE series in (37,202,203,456)) as white goods
- FROM table 1 a
- LEFT JOIN table 2 b ON b.Date = a.transaction_date
- LEFT JOIN table 3 c ON c.sku = a.product
- GROUP BY a.transaction_week
- ORDER BY a.transaction_week
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement