利用LAG分析函数把重复字段设置为空的示例如下:
测试表TEST_XX的数据如下:
要实现如下的输出结果:
具体的sql如下:
1 2 3 4 5 6 7 8 9 10 11 |
SELECT CASE WHEN PRE_NAME IS NULL THEN USER_NAME ELSE NULL END AS USER_NAME, COURSE, GRADE FROM (SELECT A.*, LAG(USER_NAME) OVER(PARTITION BY USER_NAME ORDER BY COURSE) AS PRE_NAME FROM TEST_XX A) |
原创文章,转载请注明: 转载自micmiu – 软件开发+生活点滴[ http://www.micmiu.com/ ]
0 条评论。