3 回答

TA貢獻1817條經(jīng)驗 獲得超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條經(jīng)驗 獲得超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 關注
- 2455 瀏覽
添加回答
舉報