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 help

RE: SQL help

From: Fink, Dan <Dan.Fink_at_mdx.com>
Date: Thu, 12 Sep 2002 14:58:27 -0800
Message-ID: <F001.004CF20B.20020912145827@fatcity.com>


Content-Type: text/plain;
 charset="iso-8859-1"

Rick,

    Is this in SQL*Plus? If so, use the COLUMN command to populate the column headings with the information you want. You can populate a variable with SYSDATE and use that in the column heading.  

Dan

-----Original Message-----
Sent: Thursday, September 12, 2002 4:03 PM To: Multiple recipients of list ORACLE-L

Not tested .... but

select sysdate, 'test1','test2'
from dual
where exists ( your union clause)
union
your_union_clause

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-----
<mailto:Rick_Cale_at_teamhealth.com> ]

Sent: Thursday, September 12, 2002 5:48 PM To: Multiple recipients of list ORACLE-L

Hi DBAs,

I have a query something like

SELECT sysdate,'txt1','txt2'
FROM dual
UNION
SELECT date1,txtfield1,txtfield2
FROM t1,t2,...,tn
WHERE
....... ;

The output would be one header record from the first select then the data from the second select.
If there are no records selected in second select the header record is still selected. If there are no
records in second select I do not want header record selected. How can I suppress it? I do not want to apply the where clause in 2nd select to the first because of the complexity.

Thanks
Rick

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

<http://www.orafaq.com>
-- Author: INET: Rick_Cale_at_teamhealth.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- 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_01C25AA7.E6252EF0 Content-Type: text/html; charset="iso-8859-1"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>RE: SQL help</TITLE>

<META content="MSHTML 5.50.4616.200" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=506015721-12092002><FONT face=Arial color=#0000ff
size=2>Rick,</FONT></SPAN></DIV>
<DIV><SPAN class=506015721-12092002>&nbsp;&nbsp;&nbsp; <FONT face=Arial
color=#0000ff size=2>Is this in SQL*Plus? If so, use the COLUMN command to populate the column headings with the information you want. You can populate a variable with SYSDATE and use that in the column heading.</FONT></SPAN></DIV>
<DIV><SPAN class=506015721-12092002><FONT face=Arial color=#0000ff
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=506015721-12092002><FONT face=Arial color=#0000ff
size=2>Dan</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> Jamadagni, Rajendra [mailto:Rajendra.Jamadagni_at_espn.com]<BR><B>Sent:</B> Thursday, September 12, 2002 4:03 PM<BR><B>To:</B> Multiple recipients of list ORACLE-L<BR><B>Subject:</B> RE: SQL help<BR><BR></FONT></DIV> <P><FONT size=2>Not tested .... but </FONT></P> <P><FONT size=2>select sysdate, 'test1','test2'</FONT> <BR><FONT size=2>from dual</FONT> <BR><FONT size=2>where exists ( your union clause)</FONT> <BR><FONT size=2>union</FONT> <BR><FONT size=2>your_union_clause</FONT> </P><BR> <P><FONT size=2>Raj</FONT> <BR><FONT size=2>______________________________________________________</FONT> <BR><FONT size=2>Rajendra Jamadagni&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MIS, ESPN Inc.</FONT> <BR><FONT size=2>Rajendra dot Jamadagni at ESPN dot com</FONT> <BR><FONT size=2>Any opinion expressed here is personal and doesn't reflect that of ESPN Inc. </FONT><BR><FONT size=2>QOTD: Any clod can have facts, but having an opinion is an art!</FONT> </P><BR> <P><FONT size=2>-----Original Message-----</FONT> <BR><FONT size=2>From: Rick_Cale_at_teamhealth.com [<A href="mailto:Rick_Cale_at_teamhealth.com">mailto:Rick_Cale_at_teamhealth.com</A>]</FONT> <BR><FONT size=2>Sent: Thursday, September 12, 2002 5:48 PM</FONT> <BR><FONT size=2>To: Multiple recipients of list ORACLE-L</FONT> <BR><FONT size=2>Subject: SQL help</FONT> </P><BR> <P><FONT size=2>Hi DBAs,</FONT> </P> <P><FONT size=2>I have a query something like</FONT> </P> <P><FONT size=2>SELECT sysdate,'txt1','txt2'</FONT> <BR><FONT size=2>FROM dual</FONT> <BR><FONT size=2>UNION</FONT> <BR><FONT size=2>SELECT date1,txtfield1,txtfield2</FONT> <BR><FONT size=2>FROM t1,t2,...,tn</FONT> <BR><FONT size=2>WHERE</FONT> <BR><FONT size=2>....... ;</FONT> </P> <P><FONT size=2>The output would be one header record from the first select then the data</FONT> <BR><FONT size=2>from the second select.</FONT> <BR><FONT size=2>If there are no records selected in second select the header record is</FONT> <BR><FONT size=2>still selected.&nbsp; If there are no</FONT> <BR><FONT size=2>records in second select I do not want header record selected.&nbsp; How can I</FONT> <BR><FONT size=2>suppress it? I do not want to apply the where</FONT> <BR><FONT size=2>clause in 2nd select to the first because of the complexity.</FONT> </P> <P><FONT size=2>Thanks</FONT> <BR><FONT size=2>Rick</FONT> </P><BR> <P><FONT size=2>-- </FONT><BR><FONT size=2>Please see the official ORACLE-L FAQ: <A target=_blank href="http://www.orafaq.com">http://www.orafaq.com</A></FONT> <BR><FONT size=2>-- </FONT><BR><FONT size=2>Author: </FONT><BR><FONT size=2>&nbsp; INET: Rick_Cale_at_teamhealth.com</FONT> </P> <P><FONT size=2>Fat City Network Services&nbsp;&nbsp;&nbsp; -- (858) 538-5051&nbsp; FAX: (858) 538-5051</FONT> <BR><FONT size=2>San Diego, California&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- Public Internet access / Mailing Lists</FONT> <BR><FONT size=2>--------------------------------------------------------------------</FONT> <BR><FONT size=2>To REMOVE yourself from this mailing list, send an E-Mail message</FONT> <BR><FONT size=2>to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in</FONT> <BR><FONT size=2>the message BODY, include a line containing: UNSUB ORACLE-L</FONT> <BR><FONT size=2>(or the name of mailing list you want to be removed from).&nbsp; You may</FONT> <BR><FONT size=2>also send the HELP command for other information (like subscribing).</FONT>
</P></BLOCKQUOTE></BODY></HTML>
------_=_NextPart_001_01C25AA7.E6252EF0-- -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Fink, Dan INET: Dan.Fink_at_mdx.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- 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 Thu Sep 12 2002 - 17:58:27 CDT

Original text of this message

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