PC Review


Reply
Thread Tools Rate Thread

distinct and distinctrow difference?

 
 
Tom
Guest
Posts: n/a
 
      11th Dec 2006
What is the difference between distinct and
distinctrow in SQL?


 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      11th Dec 2006
DISTINCT de-duplicates the query results based on only the fields you return
(i.e. those in the SELECT clause.) For example:
SELECT DISTINCT City FROM tblClient;
returns each city just one, regardless of how many clients are in each city.

DISTINCTROW de-duplicates based on ALL the fields. If your table has a
primary key, and the query is based on just this one table, then DISTINCTROW
makes no difference, since the primary key guarantees uniqueness.

Well, that's how it's supposed to work anyway.
In practice, Access gets DISTINCT wrong sometimes:
http://allenbrowne.com/bug-12.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Tom" <(E-Mail Removed)> wrote in message
news:yaCdnXHe_PTrf-(E-Mail Removed)...
> What is the difference between distinct and
> distinctrow in SQL?
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
get distinct data from multiple sheets & then consolidate distinct =?Utf-8?B?TmlraGls?= Microsoft Excel Programming 1 18th Sep 2006 07:01 PM
SQL Distinct / Distinctrow Steven Scaife Microsoft Access Queries 1 13th Oct 2005 11:41 AM
DISTINCTROW =?Utf-8?B?UGF1bCBmcHZ0Mg==?= Microsoft Access Queries 10 29th Sep 2004 05:29 PM
Distinct query not producing distinct results KarenM Microsoft Access 1 26th May 2004 07:41 PM
Distinct versus DistinctRow Razor Microsoft Access Queries 1 17th Dec 2003 06:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:00 PM.