Oracle row to column example

Oracle row-to-column example (reproduced)




data before row-to-column:

select * from tbname;





data after row-to-column:

select pud, listagg(ud, ',') within group(order by null) as ud
  from tbname
group by pud;





among them,

listagg(ud, ',') within group(order by null)

is the row-to-column function, and ud is the column to be converted

as ud

as ud is to anonymously give the converted column a new column name.



Finish.

-------------------------------------------------- --Reprint
address:
https://www.cnblogs.com/liudi1992/p/6039343.html
---------------------------- -------------------------

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326081313&siteId=291194637