If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Returning one of two possible values

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-13-03, 02:47
Junketfunk Junketfunk is offline
Registered User
 
Join Date: Oct 2003
Posts: 2
Returning one of two possible values

Hi guys,

I'm another newbie here.

I'm currently designing a small Access db that contains contact details:

Name
ResidentialSuburb
PostalSuburb

I need to create an SQL query that will return Name & "Suburb".
"Suburb" will contain ResidentialSuburb by default, but if this is empty, I would like it to contain PostalSuburb.

Is this possible? Im a bit stumped.

Thanks
Reply With Quote
  #2 (permalink)  
Old 10-13-03, 05:51
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Code:
select Name
     , iif(isnull(ResidentialSuburb),
         , PostalSuburb
         , iif(ResidentialSuburb=''
            , PostalSuburb
            , ResidentialSuburb)) as Suburb
  from ...
rudy
http://r937.com/
Reply With Quote
  #3 (permalink)  
Old 10-13-03, 09:02
Junketfunk Junketfunk is offline
Registered User
 
Join Date: Oct 2003
Posts: 2
Thanks Rudy,

Had a bit of a play around and it works a treat

Cheers
Matt
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On