Using groups on demand and in JPA

How will you use the following JPA query language?

select * from person where email in
(select email from person group by email having count(email)>1)
+3
source share
2 answers

Finally found a solution:

select p from Person p
where p.email in (
    select q.email
    from Person q
    group by q.email having count(q.email)>1)
order by p.email, p.id
+7
source

From this link , there is an explanation of the general structure of the SELECT SELECT query:

SELECT ... FROM ...
[WHERE ...]
[GROUP BY ... [HAVING ...]]
[ORDER BY ...]
+3
source

Source: https://habr.com/ru/post/1758721/


All Articles