select id = identity(int,1,1),* into #tmp from table
select q1,q2,q3,q4 from #tmp a where
not exists(select 1 from #tmp where q1 = a.q1 and id < a.id)
CREATE TABLE # (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[q1] [int] NULL ,
[q2] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[q3] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[q4] [char] (10) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
select * from #
insert # (q1,q2,q3,q4)
select * from a
select #.q1,#.q2,#.q3,#.q4 from # join(
select min(id) as id,q1 from # group by q1) b on #.id=b.id
drop table #
select * from del_person_temp a
where id=(select top 1 id from del_person_temp where comp_nme=a.comp_nme order by id)
select * from del_person_temp where id in(select min(id) from del_person_temp group by comp_nme)
select min(id) from del_person_temp group by comp_nme