SQLTeam.com | Weblogs | Forums

Select single records

Hi, I have a question related to a query I am writing.
Example of the table "clients":
Client ID - Type
AA1 - A
AA2 - A
AA2 - A
AA3 - A

The result of my table should give only those records where client ID is mentioned only once in the table. So in this case the result of the query should only return client AA1 and AA3, because they have only 1 occurence.

Can someone help me with the query?

SELECT [Client ID]
FROM dbo.table_name
GROUP BY [Client ID]
HAVING COUNT(*) > 1
ORDER BY [Client ID]

Thanks Scott :wink: