hibernate3.2 oracle case when 查询 问题

aa321207 2010-05-22 04:18:06
在 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)
就报不支持*的 错误
...全文
94 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
aa321207 2010-05-23
  • 打赏
  • 举报
回复
自己 顶下
aa321207 2010-05-22
  • 打赏
  • 举报
回复
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});

还是不行
aa321207 2010-05-22
  • 打赏
  • 举报
回复
我试试
ojuju10 2010-05-22
  • 打赏
  • 举报
回复

sum(case when o.orderalready='1' then o.spprice*o.num else 0 end)
将它放在外面,结果是一样的

sum(case when o.orderalready='1' then o.spprice else 0 end)*o.num
aa321207 2010-05-22
  • 打赏
  • 举报
回复
自己给自己顶下

17,082

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧