zoukankan      html  css  js  c++  java
  • JAVA Hibernate别名排序问题

    今天在做统计功能的时候遇到这样一个问题,由于查询结果为统计的数据,即使用了sum方法生成的字段,

    select refDate,sum(triggerCount) as triggerCount,sum(case when unique_key is null then 0 else trigger_count end) as hitCount from TriggerStatistic where user=:user and type=:type and refDate >=:fromDate and refDate <=:toDate group by refDate order by hitCount asc

    会提示 TriggerStatistic不存在 hitCount 属性

    于是使用查询的列序号进行排序

    查询的列有

    1:refDate

    2:triggerCount

    3:hitCount

    要对hitCount这一列进行排序 只要使用 order by 3 asc/desc

    于是改为:

    select refDate as refDate,sum(triggerCount) as triggerCount,sum(case when unique_key is null then 0 else trigger_count end) as hitCount from TriggerStatistic where user=:user and type=:type and refDate >=:fromDate and refDate <=:toDate group by refDate order by 3 asc
  • 相关阅读:
    网络基础知识
    mysql安装
    docker打包镜像
    python的基础
    python静态属性的理解
    python中的静态方法和类方法
    python类的两种创建方式
    python的继承
    python中time和datetime模块
    python之模块
  • 原文地址:https://www.cnblogs.com/rubekid/p/4604363.html
Copyright © 2011-2022 走看看