Wrox Programmer Forums
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 23rd, 2010, 09:40 AM
Authorized User
Join Date: Dec 2009
Posts: 85
Thanks: 16
Thanked 0 Times in 0 Posts
Default using DISTINCT

Hi there

I'm wanting to use in my sQl statement:

SELECT DISTINCT TOP 5 - it doesn't seem to be working for me at the moment since the top 5 that appear are not unique.

Where am I going wrong?


Old December 23rd, 2010, 04:37 PM
Friend of Wrox
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

Show the full query.

Remember, DISTINCT means "distinct in *ALL* the fields SELECTed".

If *ANY* field in the SELECT is different, then that record can *NOT* be combined with other records and so it will be DISTINCT.

Similar Threads
Thread Thread Starter Forum Replies Last Post
using DISTINCT adamhw SQL Server ASP 1 July 2nd, 2010 07:48 PM
Using Distinct Smeghead SQL Server 2005 9 December 17th, 2007 11:10 AM
Distinct Eddywardo SQL Server 2005 1 September 2nd, 2006 07:41 AM
Count Distinct Jonas Access 2 August 14th, 2006 01:03 PM
Distinct SELECT DISTINCT question... EndEffect Classic ASP Databases 4 August 18th, 2005 08:53 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.