作业帮 > 综合 > 作业

排列出相同的只显示一行 同时order by 时间怎么写

来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/08/11 10:43:41
排列出相同的只显示一行 同时order by 时间怎么写
id name index
1 mm 3
2 mm 2
3 aa 1
4 bb 4
根据index从大到小排列 重复的去掉
4 bb 4
1 mm 3
3 aa 1
大侠帮忙
排列出相同的只显示一行 同时order by 时间怎么写
select * from 表名 as a where exists (select 1 from
(select name,max(index) as index from 表名 group by name) as b
where a.name=b.name and a.index=b.index) order by a.index desc