日期:2014-05-16  浏览次数:20710 次

oracle横纵表转换的两种方式
select url,wmsys.wm_concat(alias) as alias from tableA group by url

SELECT url, LTRIM(MAX(SYS_CONNECT_BY_PATH(alias, ',')), ',') alias
  FROM (SELECT url,
               alias,
               row_number() over(PARTITION BY url ORDER BY url, alias) M,
               (ROW_NUMBER()
                OVER(ORDER BY url, alias) + (DENSE_RANK() OVER(ORDER BY url))) NUMID
          FROM (SELECT url, alias FROM tableA))
START WITH M = 1
CONNECT BY NUMID - 1 = PRIOR NUMID
GROUP BY url