打搅一下,在使用row_number() over() 分页的是否如果在select中使用了distinct去重复,这个时候distinct失效,请问这个问题该如何处理比较好?

0
已邀请:
0

- 取是能力,舍是境界 2015-12-20 回答

with tmp(月份,机器型号,数量)
as
(
    select 7,'A',5
    union all
    select 7,'B',3
    union all
    select 8,'A',5
    union all
    select 9,'B',3
    union all
    select 9,'B',3
    union all
    select 9,'A',5
    union all
    select 9,'A',5
    union all
    select 9,'C',2
)
select *,row_number() over(order by 月份) from (
    select distinct * 
        from tmp
) t 
0

li052468 2015-12-18 回答

先去重复再row_number

要回复问题请先登录注册