Oracle报错ORA-00979不是GROUP BY表达式

oracle与mysql不同,GROUP BY必须要跟select查询的所有列(除了聚合函数外) 例如:

SELECT TO_DATE(EVENTTIME) as dateTime ,OPNO as siteNum, count(*) as totalCapacity
FROM tblusercapacity
<where>
<if test="date != null">
  TO_DATE(EVENTTIME) = TO_DATE(#{date},'yyyy-mm-dd')
</if>
<if test="siteNum != null and siteNum != ''">
  AND OPNO = #{siteNum}
</if>
<if test="userNum != null">
  AND USERNO = #{userNum}
</if>
<if test="workshopNum != null">
  AND FACTORYNO = #{workshopNum}
</if>
</where>
GROUP BY opno,EVENTTIME
上一篇:SQL[Err] ORA-00979: not a GROUP BY expression


下一篇:css鼠标禁用