January 5, 2009 at 2:10 pm
I want to display a portion of a column based on another column's content.
This is the logic:
if processed = 'y' then
cc_Number = right(cc_Number, 4)
else
cc_Number = cc_Number
end if
This is what I have so far:
SELECT [Order_Amount]
,[First_Name]
,[Last_Name]
,[Middle_Name]
,isnull(processed, (right(cc_number,4)))
FROM Order_Header
Thank you in advance...
Norbert
January 5, 2009 at 2:13 pm
Lookup CASE statement in BOL. General outline is:
CASE WHEN {expression} THEN {value}
WHEN {expression} THEN {value}
ELSE {value}
END
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
January 5, 2009 at 2:16 pm
You want to use the CASE function. Something like this:
SELECT
[Order_Amount],
[First_Name],
[Last_Name],
[Middle_Name],
Case
When processed = 'Y' Then right(cc_number,4)
Else cc_number
End AS alias_name
FROM
Order_Header
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
January 6, 2009 at 10:49 am
Jeffrey and Jack
Thank you very much for your assistance. Your solutions worked perfectly!
- Norbert
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply