-
regarding the following sql:
SELECT a.lname, a.fname, a.user_id, c.address, c.city, c.zip, c.addresstypeid, d.descriptor as state
FROM users a, address c, maintstatetype d
WHERE a.user_id = c.user_id(+)
AND c.statetypeid = d.statetypeid(+)
AND c.addresstypeid in (1,2)
I have a database of users and addresses. Each user can have multiple addresses and the addresses are designated by addresstypeid. In plain english, what I want to pull is "If they have an addresstypeid of 2, use that, if not, use addresstypeid of 1".
Any help with this?
-
include decode in your select staetement:
select decode(c.addresstypeid,2,c.address2,c.address) address, a.lname, ......, blah, blah.....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|