How to find unique values without using distinct function in SQL Server ?
I have a table with multiple duplicate values.
It has 2 columns: FirstName and LastName .
Now I want to select only unique values without using Distinct function.
Please help.
Thanks
You could use Group by or Union, something like below
Select FirstName, LastName, count(*) as Count
from Name
Group by FirstName, LastName
Having Count(*) = 1
Thank you Lee_St
Almost close but I need 1 unique value from the duplicate value as well.
For example:-
FirstName LastName
A B
A B
In this case I need the answer only 1 FirstName A and LastName B
Using above query removes both A and B.
Select FirstName, LastName
from Name
Group by FirstName, LastName
Do not use having clause.
Please log in to reply to this post
You can also log in using your Facebook