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

Help with complex If The Else statement

Status
Not open for further replies.

jkupov

Technical User
Apr 28, 2004
101
US
I'm stuck on a SQL statement and am admittedly not a SQL expert. I'm accessing an Oracle DB with MS Access.

I want to write a SQL statement to display partners according to the following categories:

Preferred: those with whom we have established long standing relationships

Standard: Good partners but not frequently used

New: Relatively little information known about them- last resort

OK. Now, my issue is that I have these stored in the DB with a Y/N indicator in two fields.

pref_part_indic = Y or N
strd_part_indic= Y or N

so I want to write a statement that will look at these two fields and do the following:

If pref_part_indic is Y display "Preferred"
if strd_part_indic is Y display "Standard"
if both are fields are N display "New"

Not being a SQL expert I thought this looked easy, then discovered that I can't just write a simple If Then Else statement because I have to look at the contents of two fields.

Help...?

Joseph


 
If pref_part_indic is Y display "Preferred"
if strd_part_indic is Y display "Standard"
if both are fields are N display "New"
Code:
Iif(pref_part_indic = 'Y','Preferred',
Iif(strd_part_indic = 'Y','Standard',
'New'))
striking resemblance, don't you think? :)

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
OK... Not sure why I couldn't remember that. I was trying to write it as 2 separate statements rather than nesting another Iif into the statement. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top