vivek kumar luetel
vivek kumar luetel

Reputation: 137

How to find the duplicate salary

I'm doing like this :

SELECT salary COUNT(salary ) AS NumberOfTimes
FROM person
GROUP BY salary   
HAVING (COUNT(salary) > 1) 

Upvotes: 0

Views: 9588

Answers (2)

ADW
ADW

Reputation: 4080

Add a comma between "salary" and "COUNT(salary)".

Upvotes: 0

T.J. Crowder
T.J. Crowder

Reputation: 1074989

Other than a missing comma after the first salary, what you have is fine. You don't need the parentheses around your HAVING clause, but I can't imagine the parser cares:

SELECT salary, COUNT(salary) AS NumberOfTimes
FROM person
GROUP BY salary
HAVING COUNT(salary) > 1

Upvotes: 2

Related Questions