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 8136 · 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 1 · Viewed 70
· Posts 2 · Viewed 254
· Posts 1 · Viewed 159
· Posts 24 · Viewed 7435 · Likes 2
· Posts 26 · Viewed 2257 · Likes 5
· Posts 1 · Viewed 83
· Posts 1 · Viewed 102
· Posts 1 · Viewed 184
· Posts 2 · Viewed 286
· Posts 13 · Viewed 3452 · Likes 6



Your Banner Here
Travel Partners
Travel House Nepal