Solved

Sql Server Distinct

Posted on 2011-03-14
3
283 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

630 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