在 hibernate3.2里select o.outprovid,count(o.orderid),sum(case when o.orderalready='1' then o.spprice else 0 end) from Ordertb o 这样可以
但是改成sum(case when o.orderalready='1' then o.spprice*o.num else 0 end)
就报不支持*的 错误
...全文
945打赏收藏
hibernate3.2 oracle case when 查询 问题
在 hibernate3.2里select o.outprovid,count(o.orderid),sum(case when o.orderalready='1' then o.spprice else 0 end) from Ordertb o 这样可以 但是改成sum(case when o.orderalready='1' then o.spprice*o.num else 0 end) 就报不支持*的 错误
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: java.sql.SQLException: ORA-00979: 不是 GROUP BY 表达式
List a = manager.getList("select o.outprovid,count(o.orderid),sum(case when o.orderalready='1' then o.spprice else 0 end)*o.ordernum,sum(case when o.orderalready='1' then o.orderprice else 0 end)*o.ordernum,sum(case when o.orderalready='1' then (o.spprice-o.orderprice) else 0 end)*o.ordernum from Ordertb o where o.outprovid='"+prov.getOutProvid()+"' and o.worktime>? and o.worktime<? group by o.outprovid",new Object[]{ts,te});