How to find unique values without using distinct function in SQL Server ? - Sajha Mobile
SAJHA MOBILE
How to find unique values without using distinct function in SQL Server ?
Posts 6 · Viewed 8155 · Go to Last Post
phone
· Snapshot 0
Like · Likedby · 0
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
Lee_St
· Snapshot 24
Like · Liked by · 0
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
phone
· Snapshot 148
Like · Liked by · 0
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.
master_sajha
· Snapshot 230
Like · Liked by · 0
Select FirstName, LastName
from Name
Group by FirstName, LastName
STUPIDA
· Snapshot 237
Like · Liked by · 0
Do not use having clause.
28th amendment
· Snapshot 410
Like · Liked by · 0
ROW_NUMBER??
Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 6 · Viewed 513
· Posts 10 · Viewed 1031 · Likes 1
· Posts 1 · Viewed 89
· Posts 2 · Viewed 231
· Posts 1 · Viewed 75
· Posts 1 · Viewed 65
· Posts 3 · Viewed 785 · Likes 2
· Posts 2 · Viewed 246
· Posts 1 · Viewed 155
· Posts 1 · Viewed 129



Your Banner Here
Travel Partners
Travel House Nepal