Solved

Sql Server Distinct

Posted on 2011-03-14
3
266 Views
Last Modified: 2012-05-11
Hi,

Can you please explain how distinct will work  if we have a query like this..

select distinct ColA,ColB,ColC from EmpTable.

0
Comment
Question by:N_Sri
3 Comments
 
LVL 40

Accepted Solution

by:
Sharath earned 300 total points
ID: 35133956
It will give you a distinct record for the combination of ColA,ColB and ColC. So if you have multiple records for this combination, you will get only one record.

For example, assume you have records like this
ColA      ColB      ColC
A      B      C
A      B      C
A      B      D
B      C      D
S      C      D

with DISTINCT, you get one combination for these three columns.
ColA      ColB      ColC
A      B      C
A      B      D
B      C      D
S      C      D

Does that make sense?
0
 
LVL 32

Assisted Solution

by:ewangoya
ewangoya earned 200 total points
ID: 35133971

It means for each row selected, the combination of the fields ColA, ColB and ColC will always be unique on each row

eg
0,0,1
0,1,0
0,1,1
1,0,0
1,0,1
1,1,0
1,1,1
0
 

Author Closing Comment

by:N_Sri
ID: 35134075
thankyou
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now