Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Regardig the CASE statemet

Status
Not open for further replies.

sat6845

IS-IT--Management
Jan 19, 2005
6
US
Can any one help to create the case statement here is if/else statemet?

IF NOT ISNULL({Command.HR_ASSESSMENT_DT}) THEN
IF {Command.90_DAYS} = "N" THEN
IF {Command.HIGH_RISK_IND} = "ASSESED HIGHRISK" THEN "1B" ELSE "1C"
ELSE
IF {Command.HIGH_RISK_IND} = "ASSESED HIGHRISK" THEN "1A" ELSE "1D"
ELSE
IF {Command.90_DAYS} = "N" THEN "1E" ELSE "1F"




 
You don't expect people to write it for you do you?

Here is what you do, create the following type of code...

Code:
case when ... then ... 
     case when... then ...
          case when ... then ...
               when ... then ...
          end 
     end
end
 
Just some food for thought before you ruin what looks to be a perfectly decent IF/ELSE statement. I usually try to avoid nested CASE statements myself. Though, sometimes you can un-nest an IF/ELSE by changing it into a un-nested CASE.

You really should check your estimated execution plan in QA to verify if you need to change your IF/ELSE statement to a CASE statement. Compare it to code containing a re-written CASE statement before you make the final changes to your code. Sometimes a Case is better than an IF/Else, sometimes it's not. Before swapping out one for the other, make sure the other won't bog down your query even worse.

Does that make sense?

Catadmin - MCDBA, MCSA
"If a person is Microsoft Certified, does that mean that Microsoft pays the bills for the funny white jackets that tie in the back???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top