SQL - Having

 SELECT email as Email

From Person
Group By email
HAVING COUNT(email) > 1. // << true of false

also can multiple HAVING XXX(BBB) > CC AND ZZZ(FFF) = RR...

Input: 
Person table:
+----+---------+
| id | email   |
+----+---------+
| 1  | a@b.com |
| 2  | c@d.com |
| 3  | a@b.com |
+----+---------+
Output: 
+---------+
| Email   |
+---------+
| a@b.com |
+---------+
Explanation: a@b.com is repeated two times.

留言

此網誌的熱門文章

MAP - Sort with stream

JAVA - DSF Example