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.
精彩评论