if object_id('tb') is not null drop table tb
create table tb(gp int,seq int,va varchar(10))
go
insert into tb
select 1,2,'网上'
union all select 1,1,'门店'
union all select 1,3,'超市'
union all select 2,4,'家庭'
union all select 2,2,'公司'
union all select 2,1,'饭店'
union all select 3,4,'天空'
union all select 3,2,'河流'
union all select 3,3,'草地'
按gp分组,取出每组seq最小的记录
1 1 门店 1
2 1 饭店 1
3 2 河流 1
语句
select *
from(
select *,id=row_number()over(partition by gp order by seq )
from tb)t
where t.id=1