Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: IF in a SELECT--can you do this?
use decode in your select
-----Original Message-----
From: root_at_fatcity.com [mailto:root_at_fatcity.com] On Behalf Of Tamara Swilley Sent: Friday, November 17, 2000 6:41 PM To: Multiple recipients of list ORACLE-L Subject: IF in a SELECT--can you do this?
Hi listers; happy Friday!!
I have a question.... can you put an IF on a SELECT statement? I have a query joining 7-8 tables and I'm getting back (technically) unique rows (four columns returned) that look something like:
red blue yellow A red blue yellow P
The user says the fourth column values (for every pair of rows) can be "P and A" or "A and A". In the first case they want to see only the "P" row and in the second case, either row (since both would be "A"). How would I (1) join this table to itself with a WHERE clause to get the desired result, or (2) put a conditional IF in the SELECT so that I only get one row: a P in the case of two diff values or A in the case of two As (if this is possible)? In essence, I want to cut my results in half and only show one of two rows.
Oracle 8.0.5 on Solaris 2.6 (if it matters in this case).
Thanks in advance,
Tamara Swilley
Oracle DBA
AGENCY.COM: Vail
970-845-2173
tswilley_at_agency.com
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Tamara Swilley
INET: tswilley_at_agency.com
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Liststo: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Mon Nov 20 2000 - 02:37:50 CST
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
![]() |
![]() |