📄 求同一值的最小id.txt
字号:
id fid
1 2
2 2
3 2
4 2
5 3
6 3
7 3
8 3
我想返回这样:
id fid
1 2
5 3
/*测试数据*/
declare @tab table(id int,fid int)
insert into @tab select 1,2
union all select 2,2
union all select 3,2
union all select 4,2
union all select 5,3
union all select 6,3
union all select 7,3
union all select 8,3
select min(id)as id, b.fid from @tab a
inner join (select distinct(fid) from @tab as fid) b
on a.fid=b.fid
group by b.fid
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -