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.
group by can only be used when the other columns are the result of aggregate function (sum, count, avg, etc.), like in SQL: select column1,column2,sum(value) from FooBar group by column1, column2
- JB Nizet
yeah even I was trying to do the same just posted the wrong query before. As I have edited the question, can you please help for this modified query?
- TechnoCrat
1 Answers
12
votes
select f.column1, f.column2, min(f.value)
from FooBar f
where f.value > 100
group by f.column1, f.column2
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more
select column1,column2,sum(value) from FooBar group by column1, column2- JB Nizet