[Show all top banners]

phone
Replies to this thread:

More by phone
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 How to find unique values without using distinct function in SQL Server ?
[VIEWED 8122 TIMES]
SAVE! for ease of future access.
Posted on 01-10-19 8:47 PM     Reply [Subscribe]
Login in to Rate this Post:     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
 
Posted on 01-10-19 9:20 PM     [Snapshot: 24]     Reply [Subscribe]
Login in to Rate this Post:     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
 
Posted on 01-11-19 9:47 AM     [Snapshot: 148]     Reply [Subscribe]
Login in to Rate this Post:     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.
 
Posted on 01-11-19 3:02 PM     [Snapshot: 230]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Select FirstName, LastName
from Name
Group by FirstName, LastName
 
Posted on 01-11-19 3:27 PM     [Snapshot: 237]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Do not use having clause.
 
Posted on 01-14-19 12:37 PM     [Snapshot: 410]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 
 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 60 days
Recommended Popular Threads Controvertial Threads
What are your first memories of when Nepal Television Began?
TPS Re-registration case still pending ..
Basnet or Basnyat ??
nrn citizenship
अमेरिकामा बस्ने प्राय जस्तो नेपालीहरु सबै मध्यम बर्गीय अथवा माथि (higher than middle class)
Travelling to Nepal - TPS AP- PASSPORT
निगुरो थाहा छ ??
ढ्याउ गर्दा दसैँको खसी गनाउच
Doctors dying suddenly or unexpectedly since the rollout of COVID-19 vaccines
काेराेना सङ्क्रमणबाट बच्न Immunity बढाउन के के खाने ?How to increase immunity against COVID - 19?
TPS Work Permit/How long your took?
मन भित्र को पत्रै पत्र!
Informatica consultancy share
Travelling on TPS advance travel document to different country...
Are you ready to know the truth?
Thank you for the sajha policy
Nepali doctors future black or white usa ?
Morning dharahara
महँगो अण्डाको पिकल्प : कुखुरा र खोर भाडामा लिने
चितवनको होस्टलमा १३ वर्षीया शालिन पोखरेल झुण्डिएको अवस्था - बलात्कार पछि हत्याको शंका - होस्टेलहरु असुरक्षित
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters