|
Oh my bad! Instead of using a simple GROUP BY + MIN (), I've been following my strategy for years just because I was unable to use COUNT over grouped results. However, doing some tests now, I've found a solution.
According to what I explained in my previous message, the lack of the DISTINCT ON clause can be avoided using this:
SELECT tbl.F1, MIN (tbl.F2) FROM tbl GROUP BY tbl.F1
But, to count the results, I've came to this solution:
SELECT COUNT  FROM tbl WHERE tbl.ID = ANY (
SELECT tbl.ID FROM tbl GROUP BY tbl.F1)
It's MUCH more efficient than my previous strategy.
I feel quite silly, because I've used something similar to solve other lacks of Hibernate. But this idea didn't came to me in this case :/ . Anyway, I'm happy to have a good workaround now .
|