通过使用partition by 过滤重复项

SELECT DISTINCT b.VendorName,b.SysNo FROM shipType a WITH(NOLOCK) INNER JOIN vendor b WITH(NOLOCK)

        ON a.MerchantSysNo=b.SysNo

1.

select * from classinfo

select *,row_number() over(partition by className order by id) c from classinfo

select * from( select *,row_number() over(partition by className order by id) c from classinfo )a where a.c=1

select * from classinfo
select *,row_number() over(order by className) a from classinfo
select *,row_number() over(partition by className order by id) c from classinfo
select *,rank () over (order by className) a from classinfo
select *,dense_rank () over (order by className) a from classinfo

通过使用partition by 过滤重复项

2.使用DISTINCT 关键字 过滤重复项

SELECT DISTINCT b.VendorName,b.SysNo FROM shipType a WITH(NOLOCK) INNER JOIN vendor b WITH(NOLOCK)

        ON a.MerchantSysNo=b.SysNo

你可能感兴趣的:(partition)