Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- material,
- material_desc,
- extract_date,
- deliv_date,
- SUM(quantity) AS quantity,
- CASE
- WHEN
- (MONTH(deliv_date)=1 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=2 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=3 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=4 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=5 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=6 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=7 AND year(deliv_date)=2018) THEN '6months'
- WHEN
- (MONTH(deliv_date)=1 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=2 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=3 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=4 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=5 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=6 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=7 AND year(deliv_date)=2018 ) OR
- (MONTH(deliv_date)=8 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=9 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=10 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=11 AND year(deliv_date)=2018) OR
- (MONTH(deliv_date)=12 AND year(deliv_date)=2018) THEN '12Months'
- and same code for 18 months...
- ELSE NULL END AS Forecast_18_months
- FROM table
- GROUP BY
- material,
- material_desc,
- extract_date,
- deliv_date,
- Forecast_18_months
Add Comment
Please, Sign In to add comment