Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sql Server Distinct

Posted on 2011-03-14
3
Medium Priority
?
287 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 1200 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 800 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

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…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

963 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