I am trying to group stock levels into four columns depending on their location
This is difficult to put in words so this bit of pseudo code may explain better
I wrote this code then realised it would simply return the same figures every time.
Can any suggest how to do this better?
This is difficult to put in words so this bit of pseudo code may explain better
Code:
SELECT part, descr,
CASE WHEN loc NOT IN ('Y1','Y2','F1','F2','T1','T2',) THEN SUM(stock) AS local,
CASE WHEN loc IN ('Y1','Y2',) THEN SUM(stock) AS Yard,
CASE WHEN loc IN ('F1''F2') THEN SUM(stock) AS Field,
CASE WHEN loc IN ('T1','T2') THEN SUM(stock) AS Transit,
Can any suggest how to do this better?
Comment