34,590
社区成员
发帖
与我相关
我的任务
分享
create table Tb(file1 varchar(5),file2 int)
insert Tb
select 'A',1 union all
select 'A',2 union all
select 'B',3
select * from Tb a
where (select Count(1) from Tb where a.file1=file1 and a.file2>file2 )<1
/*
file1 file2
----- -----------
A 1
B 3
(2 行受影响)
*/
select file1,min(file2) from tb group by file1
create table Tb(file1 varchar(5),file2 int)
insert Tb
select 'A',1 union all
select 'A',2 union all
select 'B',3
SELECT FILE1,sum(FILE2) AS sum1 FROM tb GROUP BY FILE1
drop table Tb
SELECT FILE1,sum(FILE2) AS sum1
FROM tb
GROUP BY FILE1
select file1,min(file2) from tb group by file1
select * from tb t where not exists(select 1 from tb where file1=t.file1 and file2<t.file2)