-1

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": []}} 
mu is too short
  • 426,620
  • 70
  • 833
  • 800
Mona Jalal
  • 34,860
  • 64
  • 239
  • 408

3 Answers3

3
select email
from person
group by email
having count(*)>1

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

Blindy
  • 65,249
  • 10
  • 91
  • 131
1
SELECT Email
FROM Person
GROUP BY Email
HAVING COUNT(*) >1  

SQL FIDDLE

M.Ali
  • 67,945
  • 13
  • 101
  • 127
  • Thanks for introducing SQL Fiddle. But when I try your code it fails the tests `SELECT Email, COUNT(Email) AS cnt FROM Person GROUP BY Email HAVING COUNT(*) >1` – Mona Jalal Aug 09 '15 at 23:58
  • update your question with the query you have written, I cant see anything wrong with this query. – M.Ali Aug 10 '15 at 00:02
0
 select p.email from person p
 join (
 SELECT Email, COUNT(Email) AS cnt
 FROM Person
 GROUP BY Email
 HAVING count(email) > 1)  s
 on s.email = p.email

You can't use the alias of a column in the having or where clause.

Vamsi Prabhala
  • 48,685
  • 4
  • 36
  • 58