Guest User

Untitled

a guest
Jan 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. SELECT
  2. material,
  3. material_desc,
  4. extract_date,
  5. deliv_date,
  6. SUM(quantity) AS quantity,
  7. CASE
  8. WHEN
  9. (MONTH(deliv_date)=1 AND year(deliv_date)=2018) OR
  10. (MONTH(deliv_date)=2 AND year(deliv_date)=2018) OR
  11. (MONTH(deliv_date)=3 AND year(deliv_date)=2018) OR
  12. (MONTH(deliv_date)=4 AND year(deliv_date)=2018) OR
  13. (MONTH(deliv_date)=5 AND year(deliv_date)=2018) OR
  14. (MONTH(deliv_date)=6 AND year(deliv_date)=2018) OR
  15. (MONTH(deliv_date)=7 AND year(deliv_date)=2018) THEN '6months'
  16.  
  17. WHEN
  18. (MONTH(deliv_date)=1 AND year(deliv_date)=2018) OR
  19. (MONTH(deliv_date)=2 AND year(deliv_date)=2018) OR
  20. (MONTH(deliv_date)=3 AND year(deliv_date)=2018) OR
  21. (MONTH(deliv_date)=4 AND year(deliv_date)=2018) OR
  22. (MONTH(deliv_date)=5 AND year(deliv_date)=2018) OR
  23. (MONTH(deliv_date)=6 AND year(deliv_date)=2018) OR
  24. (MONTH(deliv_date)=7 AND year(deliv_date)=2018 ) OR
  25. (MONTH(deliv_date)=8 AND year(deliv_date)=2018) OR
  26. (MONTH(deliv_date)=9 AND year(deliv_date)=2018) OR
  27. (MONTH(deliv_date)=10 AND year(deliv_date)=2018) OR
  28. (MONTH(deliv_date)=11 AND year(deliv_date)=2018) OR
  29. (MONTH(deliv_date)=12 AND year(deliv_date)=2018) THEN '12Months'
  30. and same code for 18 months...
  31. ELSE NULL END AS Forecast_18_months
  32. FROM table
  33. GROUP BY
  34. material,
  35. material_desc,
  36. extract_date,
  37. deliv_date,
  38. Forecast_18_months
Add Comment
Please, Sign In to add comment