oracle 10g+ 行列转换

前端之家收集整理的这篇文章主要介绍了oracle 10g+ 行列转换前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
WITH t AS(
  SELECT 1 AS sno,1 AS cno,5 AS grade
    FROM dual
  UNION ALL
  SELECT 1,2,6
    FROM dual
  UNION ALL
  SELECT 1,3,10
    FROM dual
  UNION ALL
  SELECT 2,10
    FROM dual
  UNION ALL
  SELECT 3,1,9
    FROM dual
  UNION ALL
  SELECT 3,9
    FROM dual)
  SELECT a.sno,Max(a.aa)
    FROM (SELECT sno,wm_concat(cno || ',' || grade) over(partition BY sno order by cno,grade) AS aa
            FROM t) a
   GROUP BY a.sno;

运行一下就知道是啥意思了

原文链接:https://www.f2er.com/oracle/207338.html

猜你在找的Oracle相关文章