select *,
case when row_number() over(partition by aa order by bb)>1 then null
else qty end
from test02
select *, row_number() over(order by aa,bb ) as '行号' from test02
select *, row_number() over(partition by aa order by bb ) as '行号' from test02
case when row_number() over(partition by aa order by bb)>1 then null
else qty end
from test02
select *, row_number() over(order by aa,bb ) as '行号' from test02
select *, row_number() over(partition by aa order by bb ) as '行号' from test02
结果如下:
aa | bb | qty | 无序号 | aa | bb | qty | 无序号 | aa | bb | qty | 无序号 | ||
10 | 100 | 5 | 5 | 10 | 100 | 5 | 1 | 10 | 100 | 5 | 1 | ||
10 | 100 | 7 | NULL | 10 | 100 | 7 | 2 | 10 | 100 | 7 | 2 | ||
10 | 100 | 8 | NULL | 10 | 100 | 8 | 3 | 10 | 100 | 8 | 3 | ||
10 | 200 | 6 | NULL | 10 | 200 | 6 | 4 | 10 | 200 | 6 | 4 | ||
10 | 200 | 3 | NULL | 10 | 200 | 3 | 5 | 10 | 200 | 3 | 5 | ||
10 | 300 | 7 | NULL | 10 | 300 | 7 | 6 | 10 | 300 | 7 | 6 | ||
11 | 110 | 8 | 8 | 11 | 110 | 8 | 7 | 11 | 110 | 8 | 1 | ||
11 | 120 | 9 | NULL | 11 | 120 | 9 | 8 | 11 | 120 | 9 | 2 | ||
11 | 120 | 10 | NULL | 11 | 120 | 10 | 9 | 11 | 120 | 10 | 3 | ||
12 | 120 | 5 | 5 | 12 | 120 | 5 | 10 | 12 | 120 | 5 | 1 |