Reputation: 23
Name of table-test
Id Name Profession
1 a Engg
2 b Engg
3 c Doctor
4 d Doctor
Desired Output:
Id Name Profession
1 a Engg
4 d Doctor
I want to get rows containing unique profession as shown in the table above. I tried
hql-
"select distinct profession from test"
It's returning String profession. How can I get whole row?
Upvotes: 1
Views: 3760
Reputation: 1437
DISTINCT
will return only column with unique value.
Instead of :
select distinct profession from test
Use below hql query:
select * from test group by profession
Upvotes: 2