Solved

Sql Server Distinct

Posted on 2011-03-14
3
281 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 41

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:Ephraim Wangoya
Ephraim Wangoya 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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