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

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

  • 相关阅读:
    combiner中使用状态模式
    了解Shell
    优秀工具推荐
    linux安装weblogic10.3
    FastDFS上传下载(上)
    java压缩工具类
    06链表
    05数组
    04时间复杂度
    03复杂度
  • 原文地址:https://www.cnblogs.com/zytcomeon/p/13207611.html
Copyright © 2020-2023  润新知