用sql或函数如何将ID相同的行合并到一行
答案:2 悬赏:60 手机版
解决时间 2021-12-30 05:07
- 提问者网友:蓝琪梦莎
- 2021-12-29 06:09
用sql或函数如何将ID相同的行合并到一行
最佳答案
- 五星知识达人网友:佘樂
- 2021-12-29 06:36
SELECt *
FROM (SELECt T.ID,
LEAD(T.NAME, 0, '') OVER(PARTITION BY T.ID ORDER BY T.ID),
LEAD(T.NAME, 1, '') OVER(PARTITION BY T.ID ORDER BY T.ID),
LEAD(T.NAME, 2, '') OVER(PARTITION BY T.ID ORDER BY T.ID),
ROW_NUMBER() OVER(PARTITION BY T.ID ORDER BY T.ID) AS ROWC
FROM TAC T)
WHERe ROWC = 1;
看看这个是不是你要的~
FROM (SELECt T.ID,
LEAD(T.NAME, 0, '') OVER(PARTITION BY T.ID ORDER BY T.ID),
LEAD(T.NAME, 1, '') OVER(PARTITION BY T.ID ORDER BY T.ID),
LEAD(T.NAME, 2, '') OVER(PARTITION BY T.ID ORDER BY T.ID),
ROW_NUMBER() OVER(PARTITION BY T.ID ORDER BY T.ID) AS ROWC
FROM TAC T)
WHERe ROWC = 1;
看看这个是不是你要的~
全部回答
- 1楼网友:由着我着迷
- 2021-12-29 07:29
搜一下:用sql或函数如何将ID相同的行合并到一行
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯