I am trying to write this query in Hibernate but don't know how to do it.
This query is giving me the correct result when it's ran.
Code:
select foo.package_id,
b.title,
round(b.expected_cost) expected_cost,
round(b.expected_cost) expected_cost,
from
(select package_id, round(sum(expected_cost)) total
from ocs_dbo.emr_req_casm_final
group by package_id
order by sum(expected_cost), package_id) as foo, ocs_dbo.emr_req_casm_final b
where b.package_id= foo.package_id
order by total, b.expected_cost
Basically, I am trying to generate a report that is sorting the sum of expected_cost group by package_id
Example:
Package_id expected_cost sum_expected_cost
5 10 60
5 20 60
5 30 60
1 10 80
1 15 80
1 25 80
1 30 80
2 100 100
3 10 120
3 110 120
4 20 200
4 80 200
4 100 200
Thanks