How to do Group by query (for e.g. Select column1,column2,min(value) from Foo_Bar where value> 100 group by (Column1,Column2) ) in hibernate? I wanted to have multiple columns in group by part.
The GROUP BY clause is used along with some aggregate functions to group columns with the same values in different rows. The group by multiple columns technique retrieves grouped column values from one or more database tables by considering more than one column as grouping criteria.
The HQL Group By clause is used to group the data from the multiple records based on one or more column. It is generally used in conjunction with the aggregate functions (like SUM, COUNT, MIN, MAX and AVG) to perform an aggregation over each group.
select f.column1, f.column2, min(f.value)
from FooBar f
where f.value > 100
group by f.column1, f.column2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With