【SQL server】查询除去重复/排序

distinct使SQL查询除去重复的字段

sql语句去重,distict的用法:

select distinct 字段名from [表名]

Sql = "Select * from (Select max(可输入顺序的字段) as indexfield,要去重复字段名 From 数据表 Where  条件 Group by   要去重复字段名) as A Where 条件  order by A.indexfield"

//排序

select row_number()over(order by (select 1)) as MnuID,Name from Stutable

猜你喜欢

转载自blog.csdn.net/CountryShi/article/details/78933273