---
title: "oracle 中的行列转换"
author: "simon_zhang"
date: "2009-04-30T15:51:00Z"
tags: []
slug: "oracle"
draft: false
lastmod: "2009-04-30T15:51:00Z"
id: 377432
url: "https://mogee.iteye.com/blog/377432"
---

先贴段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)函数，对其他相同字段进行分组查询。