-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
  • 413,090
  • 67
  • 810
  • 771
Mona Jalal
  • 29,571
  • 61
  • 202
  • 359

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
  • 60,429
  • 9
  • 84
  • 123
1
SELECT Email
FROM Person
GROUP BY Email
HAVING COUNT(*) >1  

SQL FIDDLE

M.Ali
  • 65,124
  • 12
  • 92
  • 119
  • 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
  • 47,581
  • 4
  • 34
  • 53