当前位置:   article > 正文

oracle Group by 分组查询后,分页_oracle 分页 group by

oracle 分页 group by

------------恢复内容开始------------

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里。
 

------------恢复内容结束------------

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/268570
推荐阅读
相关标签
  

闽ICP备14008679号