1. 程式人生 > >distinct使SQL查詢除去重複的欄位

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 distinct(orderno),keye,key1,addtime,dtype,consignee,address,bank,tel,email,yb,invoice,content,uid from indent where keye=0 order by id desc