开发者

Using Hibernate to 'order by' a column which having a expression(sum, max, ...)?

select CONTRACT_ID, sum(PO_SPEND)
from   V_CONTRACT_ANALYSIS_202
group by  CONTRACT_ID 
order by  sum(开发者_JAVA技巧PO_SPEND) desc


From the hibernate docs

SQL functions and aggregate functions are allowed in the having and order by clauses if they are supported by the underlying database (i.e., not in MySQL).

It looks like you are using native SQL and not HQL however, but regardless of that you will need to check the database vendor docs to see if the DB supports ordering by an aggregated column. It looks correct though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜