SQL query for duplicate value in one table
SQL query for duplicate value in one table
(OP)
I have tried implementing the query to find records in one table that have equal values in one column and for some reason it does not retrieve correct result. I have been using an online SQL interpretor to access a table.Is there something wrong with this statement:
SELECT firstname FROM empinfo GROUP BY age HAVING (COUNT(age) > 1)
Thanks
SELECT firstname FROM empinfo GROUP BY age HAVING (COUNT(age) > 1)
Thanks
RE: SQL query for duplicate value in one table
SELECT A.firstname, A.age
FROM empinfo A INNER JOIN (
SELECT age FROM empinfo GROUP BY age HAVING COUNT(*) > 1
) B ON A.age = B.age
or:
SELECT firstname, age
FROM empinfo
WHERE age IN (SELECT age FROM empinfo GROUP BY age HAVING COUNT(*) > 1)
Hope This Helps, PH.
FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?
RE: SQL query for duplicate value in one table
RE: SQL query for duplicate value in one table
see either of PHV's solutions
r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
RE: SQL query for duplicate value in one table