62,250
社区成员
 发帖
 发帖 与我相关
 与我相关 我的任务
 我的任务 分享
 分享create table #temp(id int,Mobile varchar(50),mesdst varchar(30))
insert into #temp 
select 1,'11','a' union all
select 2,'11','b' union all
select 3,'22','a' union all
select 4,'22','b' union all
select 5,'22','c' union all
select 6,'33','a' union all
select 7,'33','b' union all
select * from #temp
select * from #temp t where id=(select min(id) from #temp where t.Mobile=Mobile)
declare @TB_Mobile table (id int,Mobile int,mesdst int,other varchar(1))
insert into @TB_Mobile
select 1,139139,77,'a' union all
select 2,139139,77,'b' union all
select 3,139139,77,'c' union all
select 4,139132,77,'d' union all
select 5,139132,77,'e' union all
select 6,139133,77,'f' union all
select 7,139134,77,'g' union all
select 8,139134,77,'h'
select * from @TB_Mobile a
where id=(select min(id) from @TB_Mobile 
where Mobile=a.Mobile and mesdst=a.mesdst)
order by id
/*
id          Mobile      mesdst      other
----------- ----------- ----------- -----
1           139139      77          a
4           139132      77          d
6           139133      77          f
7           139134      77          g
*/
select Distinct * from TB_Mobile