Sorry I missed one.  Try this.

SELECT 
 usr  
FROM 
  bogus
GROUP BY
 usr 
HAVING 
 SUM(DECODE(val,1,1,0)) > 0
AND
 SUM(DECODE(val,5,1,0)) > 0
AND
 SUM(DECODE(val,7,1,0)) > 0
AND
 SUM(DECODE(val,1,0,5,0,7,0,val)) = 0

Tony Aponte

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


Here's one solution.

SELECT 
 usr  
FROM 
 xxx
GROUP BY
 usr 
HAVING 
 SUM(DECODE(val,1,1,0)) > 0
AND
 SUM(DECODE(val,5,1,0)) > 0
AND
 SUM(DECODE(val,7,1,0)) > 0

HTH
Tony Aponte

-----Original Message-----
Sent: Thursday, November 13, 2003 5: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: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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: Aponte, Tony
  INET: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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: Aponte, Tony
  INET: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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).

Reply via email to