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: SQL question

RE: SQL question

From: Jamadagni, Rajendra <Rajendra.Jamadagni_at_espn.com>
Date: Mon, 23 Sep 2002 09:48:31 -0800
Message-ID: <F001.004D6CD3.20020923094831@fatcity.com>


Content-Type: multipart/alternative;
 boundary="----_=_NextPart_001_01C26320.D9067EA0" ------_=_NextPart_001_01C26320.D9067EA0
Content-Type: text/plain;
 charset="iso-8859-1"

select *
  from(select 'a' from dual union select 'b' from dual union select 'c' from dual ...)
minus
select distinct code
from table
/

HTH
Raj



Rajendra Jamadagni MIS, ESPN Inc.
Rajendra dot Jamadagni at ESPN dot com
Any opinion expressed here is personal and doesn't reflect that of ESPN Inc.

QOTD: Any clod can have facts, but having an opinion is an art!

-----Original Message-----
Sent: Monday, September 23, 2002 12:28 PM To: Multiple recipients of list ORACLE-L

Good morning list,

Environment HP-UX 11.0 Oracle 8.1.6

Can anyone help with this SQL.

I can get a result set of values from a table that match a given list of values -

select code
from table
where code in ('A','B','C','D','E')

I can get a result set of values from a table that do not match a given list of values -

select code
from table
where code not in ('A','B','C','D','E')

So far so good.

Now, how do I get the set of values from the list that do NOT have a matching value in the table?

I cannot create any objects in the schema I am working in otherwise I would create a table with the values and do a minus, but I can't figure out how to do it in SQL only.

Thanks in advance, folks.

Steve
--

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

Author: Steven Haas
  INET: steven.haas_at_snet.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).

------_=_NextPart_001_01C26320.D9067EA0
Content-Type: text/html;
 charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version = 5.5.2654.19">
<TITLE>RE: SQL question</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>select *</FONT>
<BR><FONT SIZE=3D2>&nbsp; from(select 'a' from dual union select 'b' = from dual union select 'c' from dual ...)</FONT>

<BR><FONT SIZE=3D2>minus</FONT>
<BR><FONT SIZE=3D2>select distinct code</FONT>
<BR><FONT SIZE=3D2>from table</FONT>
<BR><FONT SIZE=3D2>/</FONT>
</P>

<P><FONT SIZE=3D2>HTH</FONT>

<BR><FONT SIZE=3D2>Raj</FONT>
<BR><FONT =
SIZE=3D2>______________________________________________________</FONT>
<BR><FONT SIZE=3D2>Rajendra Jamadagni&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MIS, ESPN Inc.</FONT> <BR><FONT SIZE=3D2>Rajendra dot Jamadagni at ESPN dot com</FONT> <BR><FONT SIZE=3D2>Any opinion expressed here is personal and doesn't = reflect that of ESPN Inc. </FONT>
<BR><FONT SIZE=3D2>QOTD: Any clod can have facts, but having an opinion = is an art!</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>-----Original Message-----</FONT> <BR><FONT SIZE=3D2>From: Steven Haas [<A = HREF=3D"mailto:steven.haas_at_snet.net">mailto:steven.haas_at_snet.net</A>]</F=

ONT>
<BR><FONT SIZE=3D2>Sent: Monday, September 23, 2002 12:28 PM</FONT>
<BR><FONT SIZE=3D2>To: Multiple recipients of list ORACLE-L</FONT>
<BR><FONT SIZE=3D2>Subject: SQL question</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>Good morning list,</FONT> </P>

<P><FONT SIZE=3D2>Environment HP-UX 11.0 Oracle 8.1.6</FONT> </P>

<P><FONT SIZE=3D2>Can anyone help with this SQL.</FONT> </P>

<P><FONT SIZE=3D2>I can get a result set of values from a table</FONT>
<BR><FONT SIZE=3D2>that match a given list of values -</FONT>
</P>

<P><FONT SIZE=3D2>select code</FONT>
<BR><FONT SIZE=3D2>from table</FONT>

<BR><FONT SIZE=3D2>where code in ('A','B','C','D','E')</FONT> </P>
<P><FONT SIZE=3D2>I can get a result set of values from a table</FONT>
<BR><FONT SIZE=3D2>that do not match a given list of values -</FONT>
</P>

<P><FONT SIZE=3D2>select code</FONT>
<BR><FONT SIZE=3D2>from table</FONT>

<BR><FONT SIZE=3D2>where code not in ('A','B','C','D','E')</FONT> </P>

<P><FONT SIZE=3D2>So far so good.</FONT> </P>

<P><FONT SIZE=3D2>Now, how do I get the set of values from the = list</FONT>
<BR><FONT SIZE=3D2>that do NOT have a matching value in the = table?</FONT>
</P>

<P><FONT SIZE=3D2>I cannot create any objects in the schema I am</FONT>

<BR><FONT SIZE=3D2>working in otherwise I would create a table =
with</FONT>
<BR><FONT SIZE=3D2>the values and do a minus, but I can't figure =
out</FONT>
<BR><FONT SIZE=3D2>how to do it in SQL only.</FONT> </P>

<P><FONT SIZE=3D2>Thanks in advance, folks.</FONT> </P>

<P><FONT SIZE=3D2>Steve</FONT>
<BR><FONT SIZE=3D2>-- </FONT>
<BR><FONT SIZE=3D2>Please see the official ORACLE-L FAQ: <A =
HREF=3D"http://www.orafaq.com" =
TARGET=3D"_blank">http://www.orafaq.com</A></FONT>
<BR><FONT SIZE=3D2>-- </FONT>
<BR><FONT SIZE=3D2>Author: Steven Haas</FONT>
<BR><FONT SIZE=3D2>&nbsp; INET: steven.haas_at_snet.net</FONT>
</P>

<P><FONT SIZE=3D2>Fat City Network Services&nbsp;&nbsp;&nbsp; -- = 858-538-5051 <A HREF=3D"http://www.fatcity.com" = TARGET=3D"_blank">http://www.fatcity.com</A></FONT> <BR><FONT SIZE=3D2>San Diego, =
California&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- Mailing list = and web hosting services</FONT>
<BR><FONT =

SIZE=3D2>---------------------------------------------------------------=
------</FONT>
<BR><FONT SIZE=3D2>To REMOVE yourself from this mailing list, send an = E-Mail message</FONT>
<BR><FONT SIZE=3D2>to: ListGuru_at_fatcity.com (note EXACT spelling of = 'ListGuru') and in</FONT>
<BR><FONT SIZE=3D2>the message BODY, include a line containing: UNSUB = ORACLE-L</FONT>
<BR><FONT SIZE=3D2>(or the name of mailing list you want to be removed = from).&nbsp; You may</FONT>
<BR><FONT SIZE=3D2>also send the HELP command for other information = (like subscribing).</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C26320.D9067EA0--

------=_NextPartTM-000-f7924603-d372-4d2f-8f92-41b71eaded6e Content-Type: text/plain;
 name="ESPN_Disclaimer.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="ESPN_Disclaimer.txt"

*********************************************************************This e-mail message is confidential, intended only for the named recipient(s) above and may contain information that is privileged, attorney work product or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 and delete this e-mail message from your computer, Thank you.*********************************************************************1

------=_NextPartTM-000-f7924603-d372-4d2f-8f92-41b71eaded6e--

--

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

Author: Jamadagni, Rajendra
  INET: Rajendra.Jamadagni_at_espn.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). Received on Mon Sep 23 2002 - 12:48:31 CDT

Original text of this message

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