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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which to use, Nested Case or Nested If? 1

Status
Not open for further replies.

awholtsIT

IS-IT--Management
Aug 18, 2008
27
US
Not sure the best practice for accomplishing this requirement in a select query;

I want to query FIELD 1 in Table A
if FIELD 1 = ABC then
query another field for it's value
if FIELD 2 = XYZ then 2
else - 2
else 0

the result of this query should be placed into another field through a "as [new field name]" in that same Table A

Can someone help me with the proper syntax for this?

Thanks,

Andrew
 
case when Field1 = 'ABC' then case when field2 = 'XYZ' then 2 else -2 end else 0 end
 
That worked perfectly.

Many Thanks!!

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top