Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Silly SQL Question

RE: Silly SQL Question

From: Alan Gano <Alan.Gano_at_Banfield.net>
Date: Mon, 17 Nov 2003 13:29:36 -0800
Message-ID: <F001.005D6F3C.20031117132936@fatcity.com>


Gabriel,

How about this untested code?

Alan.

select

   usr
from

   (

      select
         usr,
         sum(decode(val,1,1,0)) look1,  -- flag for 1
         sum(decode(val,5,5,0)) look2,  -- flag for 5
         sum(decode(val,7,7,0)) look3,  -- flag for 7
         sum(decode(val,1,0,5,0,7,0,1)) look4  -- flag for others
      from the_table
      group by usr

   )
where
   look1 = 1 AND
   look2 = 1 AND
   look3 = 1 AND
   look4 = 0

/

-----Original Message-----
Sent: Thursday, November 13, 2003 2:05 PM To: Multiple recipients of list ORACLE-L

I have a table with like this:

Usr val



GAP 1
GAP 5
GAP 7
JKL 8
JKL 5 I need a query that returns the user (GAP o JKL) that has ALL the values in a list. Example: Having the list: 1,5,7 the result will be GAP, but with the values 1,5 or 1,5,7,8 there will be no result.

select distinct usr
from xxx
where val = All (1,3,5)

I was trying the ALL operator but it works with part of the list, I need the user that has (exactly) all the values in the list. Any idea?

Maybe it's a simple solution, but after several hours I feel blocked.

TIA
Gabriel



Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree
--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Gabriel Aragon
  INET: gabriel_gap_at_yahoo.com
Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: 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).
--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Alan Gano
  INET: Alan.Gano_at_Banfield.net
Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: 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 17 2003 - 15:29:36 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US