From oracle-l-bounce@freelists.org  Thu Mar  3 13:44:21 2005
Return-Path: <oracle-l-bounce@freelists.org>
Received: from air891.startdedicated.com (root@localhost)
 by orafaq.com (8.12.10/8.12.10) with ESMTP id j23JiLoK020969
 for <oracle-l@orafaq.com>; Thu, 3 Mar 2005 13:44:21 -0600
X-ClientAddr: 206.53.239.180
Received: from turing.freelists.org (freelists-180.iquest.net [206.53.239.180])
 by air891.startdedicated.com (8.12.10/8.12.10) with ESMTP id j23JiKem020965
 for <oracle-l@orafaq.com>; Thu, 3 Mar 2005 13:44:20 -0600
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 21DD97DC2C;
 Thu,  3 Mar 2005 13:42:54 -0500 (EST)
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 01606-09; Thu, 3 Mar 2005 13:42:54 -0500 (EST)
Received: from turing (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 99CC67DBBC;
 Thu,  3 Mar 2005 13:42:53 -0500 (EST)
Message-ID: <7ED53A68952D3B4C9540B4EFA5C76E362B9C78@CWYMSX04.Corp.Acxiom.net>
From: Herring Dave - dherri <Dave.Herring@acxiom.com>
To: ChrisStephens@pqa.com, oracle-l@freelists.org
Subject: RE: Nother sql question...
Date: Thu, 3 Mar 2005 12:41:02 -0600
MIME-Version: 1.0
Content-type: text/plain
Content-Transfer-Encoding: 8bit
X-archive-position: 16907
X-ecartis-version: Ecartis v1.0.0
Sender: oracle-l-bounce@freelists.org
Errors-To: oracle-l-bounce@freelists.org
X-original-sender: Dave.Herring@acxiom.com
Precedence: normal
Reply-To: Dave.Herring@acxiom.com
X-list: oracle-l
X-Virus-Scanned: by amavisd-new-20030616-p9 (Debian) at avenirtech.net
X-Spam-Checker-Version: SpamAssassin 2.60 (1.212-2003-09-23-exp) on 
 air891.startdedicated.com
X-Spam-Status: No, hits=0.0 required=5.0 tests=none autolearn=ham version=2.60
X-Spam-Level: 

Steven,

I know your post is old, but I didn't see any responses, so I thought I'd
propose the following:

SELECT SUBSTR(string,2)
  FROM (
        SELECT SYS_CONNECT_BY_PATH(name,',') string
          FROM (
                SELECT name
                     , LAG(name) OVER (ORDER BY name) prior_name
                  FROM (
                        SELECT DISTINCT name
                          FROM tableA
                         WHERE id IN (<your list of distinct ID values>)
                       )
               )
          START WITH prior_name IS NULL
        CONNECT BY PRIOR name = prior_name
        ORDER BY 1 DESC
       )
 WHERE rownum < 2
;

/*
 * Output
 */

 SUBSTR(STRING,2)
 -----------------------------------------------------------
 A,B,C

-------------------------------------
Dave Herring, DBA
Acxiom Corporation
3333 Finley
Downers Grove, IL 60515
wk: 630.944.4762
<mailto:dherri@acxiom.com>
 
Myths Resolved: "A eye for eye, tooth for tooth, ... (Ex. 21:24) is normally
quoted as justification for revenge.  On the contrary, it was commanded to
stop people from taking greater revenge than the original injustice."
-------------------------------------

> -----Original Message-----
> From: oracle-l-bounce@freelists.org [mailto:oracle-l-bounce@freelists.org]
> On Behalf Of Stephens, Chris
> Sent: Wednesday, November 10, 2004 1:21 PM
> To: oracle-l@freelists.org
> Subject: Nother sql question...
> 
> 
> I have a list of id's passed in.  I need a string of names returned that
> coincide with those id's.  It's very easy to just create a cursor, loop
> through, and concantenate to the string on every iteration but I was
> thinking there would be a way to do this in sql with one of the new
> analytic functions but nothing is really jumping out at me.
> 
> Anyone?
> 
> tableA
> Id   Name
> 1    A
> 2    B
> 3    C
> 
> Sql>fReturnString(1,2,3);
> Sql>a,b,c
> 
> 
> --
> http://www.freelists.org/webpage/oracle-l


**********************************************************************
The information contained in this communication is
confidential, is intended only for the use of the recipient
named above, and may be legally privileged.
If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, 
distribution, or copying of this communication is strictly
prohibited.
If you have received this communication in error,
please re-send this communication to the sender and
delete the original message or any copy of it from your
computer system. Thank You.

--
http://www.freelists.org/webpage/oracle-l

