[thelist] MS SS7 - SELECT [computed field] syntax question
Luther, Ron
Ron.Luther at hp.com
Fri Jan 25 12:47:59 CST 2008
Matt Warden also suggested 'case':
>>I don't know about MS SQL's special sauce way of doing it, but this is how I'd do it:
>>(case when Field_1='XX' and Field_2='YY' then 'New Value' else Field_3
>>end) as New_field_3
Hi Matt,
Yeah. It took a few minutes for the brain cells to warm up and remember 'case'
this morning. (Too many Oracle [decode]s I guess.)
After a bit, I had this part working (Okay - so I pretty much cut and pasted it
from the MSDN T-SQL on-line reference ... but with the amount of effort it
took me to find it in there (Grrrr) I figger I earned it!):
SELECT
Field_1,
CASE Field_2
WHEN 'UN' THEN 'United We Stand'
WHEN 'OP' THEN 'Opt for more beer!'
ELSE 'Not for sale'
END AS Report_Cat,
FROM dishere_table
Unfortunately, other forest fires started flaring up and I didn't get a chance
to test [AND] [.AND.] [||] and/or nested [CASE] statements to try to get the
'compound' portion of the expression working.
This is a winner. Thanks much for the heads up!!
RonL.
More information about the thelist
mailing list