oracle 中的行列转换

先贴段sql

SELECT   lineleveltext, taskid, taskname, excutetimes, taskpoint, linelevel,
         evaluatepoint, wmsys.wm_concat (taskop)
    FROM (SELECT l.NAME lineleveltext, b.ID taskid, b.describtion taskname,
                 b.excutetimes excutetimes, b.taskpoint taskpoint,
                 o.operationname taskop, b.linelevel linelevel,
                 b.evaluatepoint evaluatepoint
            FROM plantasklist a,
                 taskinfo b,
                 lineclassdic l,
                 taskoperationlist ol,
                 taskoperation o
           WHERE l.code = b.linelevel
             AND a.taskid = b.ID
             AND ol.taskid = b.ID
             AND ol.operationid = o.ID
             AND a.planid = '00000000000000000844')
GROUP BY lineleveltext,
         taskid,
         taskname,
         excutetimes,
         taskpoint,
         linelevel,
         evaluatepoint,
         linelevel

在多表关联查询时,有时或出现多行纪录,但就有一个字段不同。可以采用wmsys.wm_concat (taskop)函数,对其他相同字段进行分组查询。

你可能感兴趣的:(oracle,sql)