sql实现分组并排序
时间:2015-01-15 10:59:57
收藏:0
阅读:323
今天遇到一个sql,分组求和过后排序,就想一句sql实现
开始是这么想的:
select re.c, re.d from (select c, max(d) as d from a group by c) re order by re.d desc
总感觉重复啰嗦,就百度了一下下(以为要用having,结果就下面简单一句搞定):
select c,max(d) from a group by c order by max(d) desc
原文:http://blog.csdn.net/hgg923/article/details/42737237
评论(0)