Return-Path: <root@fatcity.cts.com>
Received: from newsfeed.cts.com (newsfeed.cts.com [209.68.248.164])
 by naude.co.za (8.11.2/8.11.2) with SMTP id g7KLW0U32342
 for <oracle-l@naude.co.za>; Tue, 20 Aug 2002 17:32:00 -0400
Received: from fatcity.UUCP (uucp@localhost)
 by newsfeed.cts.com (8.9.3/8.9.3) with UUCP id OAA05687;
 Tue, 20 Aug 2002 14:30:21 -0700 (PDT)
Received: by fatcity.com (26-Feb-2001/v1.0g-b71/bab) via UUCP id 004BA5EB; Tue, 20 Aug 2002 12:28:30 -0800
Message-ID: <F001.004BA5EB.20020820122830@fatcity.com>
Date: Tue, 20 Aug 2002 12:28:30 -0800
To: Multiple recipients of list ORACLE-L <ORACLE-L@fatcity.com>
X-Comment: Oracle RDBMS Community Forum
X-Sender: "Jamadagni, Rajendra" <Rajendra.Jamadagni@espn.com>
Sender: root@fatcity.com
Reply-To: ORACLE-L@fatcity.com
Errors-To: ML-ERRORS@fatcity.com
From: "Jamadagni, Rajendra" <Rajendra.Jamadagni@espn.com>
Subject: RE: simple problem
Organization: Fat City Network Services, San Diego, California
X-ListServer: v1.0g, build 71; ListGuru (c) 1996-2001 Bruce A. Bergman
Precedence: bulk
Mime-Version: 1.0
Content-Type: multipart/mixed;	boundary="----=_NextPartTM-000-e9839db3-b46a-11d6-a0dc-00508bbd2e09"
------=_NextPartTM-000-e9839db3-b46a-11d6-a0dc-00508bbd2e09
Content-Type: multipart/alternative;
 boundary="----_=_NextPart_001_01C2487F.915AAB00"
------_=_NextPart_001_01C2487F.915AAB00
Content-Type: text/plain;
 charset="iso-8859-1"

create or replace mystrtype is table of varchar2(50)
/
select field1, cast(multiset(field2) as mystrtype)
  from my_table
 group by field1
/
 
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: Tuesday, August 20, 2002 3:34 PM
To: Multiple recipients of list ORACLE-L


Here's an answer I posted to a similar question a few weeks ago.
 
HTH
 
Tony Aponte
 
 
  

I hope this is not to late for you.  Anyway, this questions comes up often.
Below is the solution to pivot rows for up to 12 values of field1.  Just
adjust to fit your range of values.

HTH 
Tony Aponte 
Home Shopping Network, Inc. 

create table tab1 (field1 number,field2 varchar2(30)); 
insert into tab1 values( 1,'RAM'); 
insert into tab1 values( 1,'SHAM'); 
insert into tab1 values( 1,'PAT'); 
insert into tab1 values( 2,'MAN'); 
insert into tab1 values( 2,'JOHN'); 
commit; 

SELECT 
g1 
,MAX(DECODE(line_no,01,value,NULL)) || 
MAX(DECODE(line_no,02,value,NULL)) || 
MAX(DECODE(line_no,03,value,NULL)) || 
MAX(DECODE(line_no,04,value,NULL)) || 
MAX(DECODE(line_no,05,value,NULL)) || 
MAX(DECODE(line_no,06,value,NULL)) || 
MAX(DECODE(line_no,07,value,NULL)) || 
MAX(DECODE(line_no,08,value,NULL)) || 
MAX(DECODE(line_no,09,value,NULL)) || 
MAX(DECODE(line_no,10,value,NULL)) || 
MAX(DECODE(line_no,11,value,NULL)) || 
MAX(DECODE(line_no,12,value,NULL)) 
FROM (SELECT g1,value,row_number() over(partition by g1 order by g1 nulls
last) line_no 
FROM (SELECT field1 g1,field2 value from tab1) 
) 
GROUP BY g1; 


G1      MAX(DECODE(LINE_NO,01,VALUE,NU 
1       RAMSHAMPAT 
2       MANJOHN 

-----Original Message----- 
[ mailto:RShankar1@CHN.COGNIZANT.COM <mailto:RShankar1@CHN.COGNIZANT.COM> ] 
Sent: Thursday, July 18, 2002 4:35 PM 
To: Multiple recipients of list ORACLE-L 


Hi Friends, 
        I just need a help in a sql . I am having rows in a table as follows


Field1(ID)    Field2(NAME) 
-------------------------- 
1                 RAM 
1                 SHAM 
1                 PAT 
2                 MAN 
2                 JOHN 

Now i want the output to be as follows 

FIELD1  FIELD2 
------------------ 
1               RAMSHAMPAT 
2               MANJOHN 

In the output i have to show all the names for the same id in a single row. 
Please help me in getting this output using a SQL query  and not through 
cursors. 

Thanks in advance. 

Regards, 
Shankar 

 
 

-----Original Message-----
Sent: Tuesday, August 20, 2002 9:53 AM
To: Multiple recipients of list ORACLE-L


Hi Lists!
 I have one simple problem.  My query is following 

SELECT SOD.DESCRIPTION
FROM 
SO_TRN_DETAIL SOD
WHERE
SOD.SO_TRN_ID =90
and result is : 
 PREM_NET
 TAX_SPF
 TAX_SUR
 FEE_PDCR
 FEE_INSP
 PREM_GROSS
 COM_GROSS
 COM_PDCR
 
I want to concatenate all strings in a single string and want to display as
a single record using SQL. I had seen solution somewhere but i can not
search in archive.  
How to do that?
 
Thanks in advance ...
Shishir Kumar Mishra
Agni Software (P) Ltd.
www.agnisoft.com <http://www.agnisoft.com> 
----------------------------------
Vidya Dadaati Viniyam
----------------------------------
 
 


------_=_NextPart_001_01C2487F.915AAB00
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">


<META content="MSHTML 5.50.4522.1800" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=098362119-20082002><FONT face="Courier New" color=#0000ff 
size=2>create or replace mystrtype is table of varchar2(50)</FONT></SPAN></DIV>
<DIV><SPAN class=098362119-20082002><FONT face="Courier New" color=#0000ff 
size=2>/</FONT></SPAN></DIV>
<DIV><SPAN class=098362119-20082002><FONT face="Courier New" color=#0000ff 
size=2>select field1, cast(multiset(field2) as mystrtype)</FONT></SPAN></DIV>
<DIV><SPAN class=098362119-20082002><FONT face="Courier New" color=#0000ff 
size=2>&nbsp; from my_table</FONT></SPAN></DIV>
<DIV><SPAN class=098362119-20082002><FONT face="Courier New" color=#0000ff 
size=2>&nbsp;group by field1</FONT></SPAN></DIV>
<DIV><SPAN class=098362119-20082002><FONT face="Courier New" color=#0000ff 
size=2>/</FONT></SPAN></DIV>
<DIV><FONT face="Courier New" color=#0000ff size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=098362119-20082002><FONT face="Courier New" color=#0000ff 
size=2>HTH</FONT></SPAN></DIV>
<DIV><SPAN class=098362119-20082002><FONT face="Courier New" color=#0000ff 
size=2>Raj</FONT></SPAN></DIV>
<DIV><SPAN class=098362119-20082002></SPAN><FONT face="Courier New" 
size=2>______________________________________________________</FONT></DIV>
<P align=left><FONT face="Courier New" size=2>Rajendra 
Jamadagni&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MIS, ESPN Inc.</FONT></P>
<P align=left><FONT face="Courier New" size=2>Rajendra dot Jamadagni at ESPN dot 
com</FONT></P>
<P align=left><FONT face="Courier New" size=2>Any opinion expressed here is 
personal and doesn't reflect that of ESPN Inc. </FONT></P>
<P align=left><FONT face="Courier New" size=2>QOTD: Any clod can have facts, but 
having an</FONT> <FONT face="Courier New" size=2>opinion is an</FONT> <FONT 
face="Courier New" size=2>art!</FONT></P>
<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> Aponte, Tony 
  [mailto:AponteT@hsn.net]<BR><B>Sent:</B> Tuesday, August 20, 2002 3:34 
  PM<BR><B>To:</B> Multiple recipients of list ORACLE-L<BR><B>Subject:</B> RE: 
  simple problem<BR><BR></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=212142618-20082002>Here's an answer I posted to a similar question a few 
  weeks ago.</SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=212142618-20082002></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=212142618-20082002>HTH</SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=212142618-20082002></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN class=212142618-20082002>Tony 
  Aponte</SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=212142618-20082002></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=212142618-20082002></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN class=212142618-20082002><!-- Converted from text/plain format --><FONT 
  face="Times New Roman" color=#000000 size=3>&nbsp;</FONT> 
  <P><FONT size=2>I hope this is not to late for you.&nbsp; Anyway, this 
  questions comes up often.&nbsp; Below is the solution to pivot rows for up to 
  12 values of field1.&nbsp; Just adjust to fit your range of values.</FONT></P>
  <P><FONT size=2>HTH</FONT> <BR><FONT size=2>Tony Aponte</FONT> <BR><FONT 
  size=2>Home Shopping Network, Inc.</FONT> </P>
  <P><FONT size=2>create table tab1 (field1 number,field2 varchar2(30));</FONT> 
  <BR><FONT size=2>insert into tab1 values( 1,'RAM');</FONT> <BR><FONT 
  size=2>insert into tab1 values( 1,'SHAM');</FONT> <BR><FONT size=2>insert into 
  tab1 values( 1,'PAT');</FONT> <BR><FONT size=2>insert into tab1 values( 
  2,'MAN');</FONT> <BR><FONT size=2>insert into tab1 values( 2,'JOHN');</FONT> 
  <BR><FONT size=2>commit;</FONT> </P>
  <P><FONT size=2>SELECT </FONT><BR><FONT size=2>g1 </FONT><BR><FONT 
  size=2>,MAX(DECODE(line_no,01,value,NULL)) || </FONT><BR><FONT 
  size=2>MAX(DECODE(line_no,02,value,NULL)) || </FONT><BR><FONT 
  size=2>MAX(DECODE(line_no,03,value,NULL)) || </FONT><BR><FONT 
  size=2>MAX(DECODE(line_no,04,value,NULL)) || </FONT><BR><FONT 
  size=2>MAX(DECODE(line_no,05,value,NULL)) || </FONT><BR><FONT 
  size=2>MAX(DECODE(line_no,06,value,NULL)) || </FONT><BR><FONT 
  size=2>MAX(DECODE(line_no,07,value,NULL)) || </FONT><BR><FONT 
  size=2>MAX(DECODE(line_no,08,value,NULL)) || </FONT><BR><FONT 
  size=2>MAX(DECODE(line_no,09,value,NULL)) || </FONT><BR><FONT 
  size=2>MAX(DECODE(line_no,10,value,NULL)) || </FONT><BR><FONT 
  size=2>MAX(DECODE(line_no,11,value,NULL)) || </FONT><BR><FONT 
  size=2>MAX(DECODE(line_no,12,value,NULL)) </FONT><BR><FONT size=2>FROM (SELECT 
  g1,value,row_number() over(partition by g1 order by g1 nulls last) line_no 
  </FONT><BR><FONT size=2>FROM (SELECT field1 g1,field2 value from tab1) 
  </FONT><BR><FONT size=2>) </FONT><BR><FONT size=2>GROUP BY g1;</FONT> </P><BR>
  <P><FONT size=2>G1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  MAX(DECODE(LINE_NO,01,VALUE,NU</FONT> <BR><FONT 
  size=2>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RAMSHAMPAT</FONT> <BR><FONT 
  size=2>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MANJOHN</FONT> </P>
  <P><FONT size=2>-----Original Message-----</FONT> <BR><FONT size=2>From: 
  Ramasubramanian, Shankar (Cognizant)</FONT> <BR><FONT size=2>[<A 
  href="mailto:RShankar1@CHN.COGNIZANT.COM">mailto:RShankar1@CHN.COGNIZANT.COM</A>]</FONT> 
  <BR><FONT size=2>Sent: Thursday, July 18, 2002 4:35 PM</FONT> <BR><FONT 
  size=2>To: Multiple recipients of list ORACLE-L</FONT> <BR><FONT 
  size=2>Subject: SQL Query</FONT> </P><BR>
  <P><FONT size=2>Hi Friends,</FONT> 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>I just need a help 
  in a sql . I am having rows in a table as follows</FONT> </P>
  <P><FONT size=2>Field1(ID)&nbsp;&nbsp;&nbsp; Field2(NAME)</FONT> <BR><FONT 
  size=2>--------------------------</FONT> <BR><FONT 
  size=2>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; RAM</FONT> <BR><FONT 
  size=2>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; SHAM</FONT> <BR><FONT 
  size=2>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; PAT</FONT> <BR><FONT 
  size=2>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; MAN</FONT> <BR><FONT 
  size=2>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; JOHN</FONT> </P>
  <P><FONT size=2>Now i want the output to be as follows</FONT> </P>
  <P><FONT size=2>FIELD1&nbsp; FIELD2</FONT> <BR><FONT 
  size=2>------------------</FONT> <BR><FONT 
  size=2>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RAMSHAMPAT</FONT> <BR><FONT 
  size=2>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MANJOHN</FONT> </P>
  <P><FONT size=2>In the output i have to show all the names for the same id in 
  a single row.</FONT> <BR><FONT size=2>Please help me in getting this output 
  using a SQL query&nbsp; and not through</FONT> <BR><FONT 
  size=2>cursors.</FONT> </P>
  <P><FONT size=2>Thanks in advance.</FONT> </P>
  <P><FONT size=2>Regards,</FONT> <BR><FONT size=2>Shankar</FONT> 
  </P></SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=212142618-20082002></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=212142618-20082002></SPAN></FONT>&nbsp;</DIV>
  <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
    <DIV class=OutlookMessageHeader><FONT face="Times New Roman" 
    size=2>-----Original Message-----<BR><B>From:</B> Shishir Kumar Mishra 
    [mailto:shishir@agnisoft.com]<BR><B>Sent:</B> Tuesday, August 20, 2002 9:53 
    AM<BR><B>To:</B> Multiple recipients of list ORACLE-L<BR><B>Subject:</B> 
    simple problem<BR><BR></FONT></DIV>
    <DIV><FONT face=Arial size=2>Hi Lists!</FONT></DIV>
    <DIV><FONT face=Arial size=2>&nbsp;I have one simple problem.&nbsp; My query 
    is following&nbsp;<BR><BR></FONT><FONT size=1><B>SELECT</B> 
    SOD.DESCRIPTION<BR><B>FROM</B> <BR>SO_TRN_DETAIL 
    SOD<BR><B>WHERE</B><BR>SOD.SO_TRN_ID =<FONT 
    color=#0000f0>90</FONT></FONT></DIV>
    <DIV><FONT face=Arial size=2>and result is :&nbsp;</FONT></DIV>
    <DIV><FONT face=Arial size=2>&nbsp;</FONT><FONT face=Arial 
    size=1>PREM_NET<BR>&nbsp;TAX_SPF<BR>&nbsp;TAX_SUR<BR>&nbsp;FEE_PDCR<BR>&nbsp;FEE_INSP<BR>&nbsp;PREM_GROSS<BR>&nbsp;COM_GROSS<BR>&nbsp;COM_PDCR</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>I want to concatenate all strings in a single 
    string and want to display as a single record&nbsp;using SQL. I had seen 
    solution somewhere but i can not search in archive.&nbsp; </FONT></DIV>
    <DIV><FONT face=Arial size=2>How to do that?</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>Thanks in advance ...<BR></FONT><FONT 
    face=Arial size=2>Shishir Kumar Mishra<BR>Agni Software (P) Ltd.<BR><A 
    href="http://www.agnisoft.com">www.agnisoft.com</A><BR>----------------------------------<BR>Vidya 
    Dadaati Viniyam<BR>----------------------------------</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial 
size=2></FONT>&nbsp;</DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C2487F.915AAB00--


------=_NextPartTM-000-e9839db3-b46a-11d6-a0dc-00508bbd2e09
Content-Type: text/plain;
 name="ESPN_Disclaimer.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="ESPN_Disclaimer.txt"


*********************************************************************2

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.

*********************************************************************2


------=_NextPartTM-000-e9839db3-b46a-11d6-a0dc-00508bbd2e09--

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Jamadagni, Rajendra
  INET: Rajendra.Jamadagni@espn.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@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).

