3 回答

TA贡献1817条经验 获得超6个赞
A表 A1
B表 B1,B2
C表C1,C2
SQL如下
1 2 3 4 5 6 7 8 9 10 11 | select case r1 when 1 then A1 else '' end as A1, case r2 when 1 then B2 else '' end as B2, case r3 when 1 then C2 else '' end as C2 from ( select A1,B2,C2 row_number() over (partiotion by A1 by B2,C2) as r1, row_number() over (partiotion by A1,B2 by C2) as r2, row_number() over (partiotion by A1,C2 by B2) as r3 from A,B,C where A.A1 = B.B1 and A.A1 = C.C1 ) T |

TA贡献1765条经验 获得超5个赞
对,是少个逗号
1 2 3 4 5 6 7 8 9 10 11 | select case r1 when 1 then A1 else '' end as A1, case r2 when 1 then B2 else '' end as B2, case r3 when 1 then C2 else '' end as C2 from ( select A1,B2,C2, row_number() over (partiotion by A1 by B2,C2) as r1, row_number() over (partiotion by A1,B2 by C2) as r2, row_number() over (partiotion by A1,C2 by B2) as r3 from A,B,C where A.A1 = B.B1 and A.A1 = C.C1 ) T |
把rownumber()换成row_number()
- 3 回答
- 0 关注
- 2434 浏览
添加回答
举报