Re: sql help, please

From: Michael Moore <michaeljmoore_at_gmail.com>
Date: Tue, 26 Jan 2010 15:49:12 -0800
Message-ID: <26fdee6e1001261549r69c194e2s5e517409043266a7_at_mail.gmail.com>



or even better ...
SELECT     animal, LTRIM( SYS_CONNECT_BY_PATH( grp, ',' ), ',' ) csv_list
      FROM ( SELECT animal,
                    ROW_NUMBER( ) OVER( PARTITION BY animal ORDER BY 1 )
rnum,
                    grp,
                    COUNT( * ) OVER( PARTITION BY animal ) cnt
              FROM c )
     WHERE rnum = cnt
CONNECT BY animal = PRIOR animal AND   rnum
                                     - 1 = PRIOR rnum
START WITH rnum = 1;
--
http://www.freelists.org/webpage/oracle-l
Received on Tue Jan 26 2010 - 17:49:12 CST

Original text of this message