问题描述
- 关于mysql中order by与group by的问题
- select * from (select * from t2 order by gidcol2 desc) as t group by gid
这条sql语句执行完之后,为什么gid的排序是增序的???
解决方案
(select * from t2 order by gid desccol2 desc)
给gid加个desc
解决方案二:
语句先执行select * from t2 order by gidcol2 desc 对gid的排序,然后在分组的
解决方案三:
select * from t2 order by gidcol2 desc执行过后取结果作为t
select * from t group by gid
这样每组都会取第一条显示出来
解决方案四:
虽然你子查询中是降序的,但你外面没有指定,所以缺省还是按升序排得。所以你需要显示指定order by xx desc
解决方案五:
select * from (select * from t2 order by gidcol2 desc) as t group by gid 子句这么order by意义不大,放到最外层吧 select * from (select * from t2 ) as t group by gid order by gid desc 倒序写desc
解决方案六:
因为默认的就是升序。应该在最外部加上这句话order by gidcol2 desc。
select * from (select * from t2) as t group by gid order by gidcol2 desc
解决方案七:
select * from t2 group by gid order by col2 desc
解决方案八:
select * from (select * from t2 order by gidcol2 desc) as t group by** t.gid**
解决方案九:
谢谢诸位了,问题已经解决了。
解决方案十:
对,到最后面价格desc 的
时间: 2024-11-17 01:12:25