Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL query for duplicate value in one table

Status
Not open for further replies.

jDevon

Technical User
Dec 15, 2008
1
US
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
 
Either:
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
FAQ181-2886
 
SELECT firstname,age FROM empinfo GROUP BY age HAVING (COUNT(age) > 1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top