赞
踩
------------恢复内容开始------------
1.分页查询 select count(*) times,title from menulog group by title order by count(*) desc
2, 生成一个带rn字段的表tableRN=(SELECT rownum as rn, a.* FROM (select count(*) times,title from menulog group by title order by count(*) desc ) a)
3 select * from tableRN where rn between 0 and 6
select * from(SELECT rownum as rn, a.* FROM (select count(*) times,title from menulog group by title order by count(*) desc ) a)
where rn between 0 and 6
-----------------------
select count(*) times,max(url), title from menulog b group by title order by count(*) desc
------------------------
今天看公司的代码,看到很多max或者sum某个字段的值这样无意义的写法,一开始很疑惑这样写是为了什么。
后来了解到,原来和后面使用到的group by有关,只要select的,不调用聚合函数的,一定要出现在group by里,而group by里出现的,不一定在出现在select里。
------------恢复内容结束------------
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。