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

来源:互联网 发布:淘宝网天天特价女装 编辑:程序博客网 时间:2024/05/19 16:19

sql语句去重,distict的用法:

select distinct 字段名 from [表名]

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

例子:

select distinct(orderno),keye,key1,addtime,dtype,consignee,address,bank,tel,email,yb,invoice,content,uid from indent where keye=0 order by id desc

转自:http://www.cnblogs.com/ATree/archive/2010/04/18/sql-distinct.html

0 0
原创粉丝点击