SQL语句中distinct的分页和查询数据数量
SQL语句中distinct的分页和查询数据数量
⾸先distinct在SQL语句中是⽤来过滤的作⽤
例如(在Table中有多个重复的Name我们可以这样过滤掉多个多余的Name留下唯⼀⼀个)
select distinct Name from  Table
我们如果想要查询过滤出来的数据数量可以distinct查询
select count(distinct Name) from Table
如果想要distinct查询出来的数据分页
select distinct top 10 Name * from (select row_number() over(order by a.Id desc)as rownumber,a.Name from Table a)as temp_order where rownumber>0
分页只需把rownumber变动可以分页了