Friday, 16 September 2016

sql - How to findi duplicate entries in MySQL




I am trying this code:




SELECT Email FROM 
(SELECT Email, COUNT(Email) AS cnt
FROM Person
GROUP BY Email
HAVING cnt(*) >1 )


for this question:
enter image description here
Not sure what I am getting wrong?




Here's the error I receive:



 Runtime Error Message: Line 6: SyntaxError: near '*) >1 )'
Last executed input: {"headers": {"Person": ["Id", "Email"]}, "rows": {"Person": []}}

Answer



select email
from person
group by email

having count(*)>1


You don't need the nested queries for what you want.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...