Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple columns in group by clause in hibernate

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.

like image 960
TechnoCrat Avatar asked May 17 '12 17:05

TechnoCrat


People also ask

Can group by clause have multiple columns?

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.

Can we use group by in HQL?

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.


1 Answers

select f.column1, f.column2, min(f.value)
from FooBar f
where f.value > 100
group by f.column1, f.column2
like image 131
JB Nizet Avatar answered Nov 07 '22 08:11

JB Nizet