时间:2021-07-01 10:21:17 帮助过:16人阅读
slect name,add,num from test group by add order by add desc
slect name,add,num from test group by add order by add desc
每个name最大的一行
select *
from test a
where not exists (select 1 from test where name=a.name and num>a.num);
第一问
select * from (select * from test order by num desc) t group by name
name add num a wefsv 3 as w3rs 13 b w1rs 10
第一问
select * from (select * from test order by num desc) t group by name
name add num a wefsv 3 as w3rs 13 b w1rs 10
1 行
select * from test a where 0 = (select count(*) from test where name = a.name and num > a.num)
2 行
select * from test a where 2 > (select count(*) from test where name = a.name and num > a.num)
1 行
select * from test a where 0 = (select count(*) from test where name = a.name and num > a.num)
2 行
select * from test a where 2 > (select count(*) from test where name = a.name and num > a.num)
问题二
select * from test t where 2>(select count(*) from test where num>t.num and name=t.name);
name add num a wefsv 3 b wers 9 b w1rs 10 as wers 12 as w3rs 13