1

I need Postgres DISTINCT ON equivalent in HQL. For example consider the following.

SELECT DISTINCT ON (Col2) Col1, Col4 FROM tablename;

on table

Col1 | Col2 | Col3 | Col4
---------------------------------
AA1  | A    |  2    | 1
AA2  | A    |  4    | 2
BB1  | B    |  2    | 3
BB2  | B    |  5    | 4

Col2 will not be shown in the result as below

Col1 | Col4
------------
AA1  |  1
BB1  |  3

Can anyone give a solution in HQL. I need to use DISTINCT as it is part of a bigger query.

Khaino
  • 3,774
  • 1
  • 27
  • 36

1 Answers1

2

Sorry but I misread your question:

No, Hibernate does not support a DISTINCT ON query.

Here is possible duplicate of your question: Postgresql 'select distinct on' in hibernate

Community
  • 1
  • 1
jarvo69
  • 7,908
  • 2
  • 18
  • 28