Hi, Can anyone help with my query. I have the following case statement. I am trying to set one variable, once I have set the first variable with the value, based on this value I want to set another variable. A kind of nested case I guess but not sure!!
My query is:-
SELECT placeref, mgearea, 'area' =
CASE
WHEN mgearea IN ('Alton','Kingsley')
THEN 'Cheadle'
WHEN mgearea IN('holby','Biddulph Moor')
THEN 'Biddulph'
ELSE 'Other'
END
FROM tempdb..people
ORDER BY placeref
INSERT INTO #tmp_mareas
Need to say if its Cheadle then SubArea = CHTOWN
so I would want my output to look like this:-
placeref mgearea area subarea
CHL0012 Alton Cheadle CHLTOWN
etc...
anyones help is much appreciated.
My query is:-
SELECT placeref, mgearea, 'area' =
CASE
WHEN mgearea IN ('Alton','Kingsley')
THEN 'Cheadle'
WHEN mgearea IN('holby','Biddulph Moor')
THEN 'Biddulph'
ELSE 'Other'
END
FROM tempdb..people
ORDER BY placeref
INSERT INTO #tmp_mareas
Need to say if its Cheadle then SubArea = CHTOWN
so I would want my output to look like this:-
placeref mgearea area subarea
CHL0012 Alton Cheadle CHLTOWN
etc...
anyones help is much appreciated.