Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query help with TOP 10 clause

Author  Topic 

mcgilles
Starting Member

1 Post

Posted - 2009-01-23 : 10:53:17
I have a query using a SELECT TOP 10. the query is working but the top 10 is not working the way I thought it would. it is returning all results which are in the top 10 of the result values.

my data in the database is:
8
7
5
4
2
2
2
1
1
1
1
1
1
1
1
and a bunch of 0's

the table contains other information of course, it is a list of the number of occurrences of a certain error message.

the problem is when using the top 10 clause it is returning all of these records, 16 total. I only wanted the top 10! I know the clause has a ties command you can use, but I am not using the WITH TIES command, I want the query to return strictly 10 results, how can I do this?

the query is actually being run in Access pulling data from an ODBC linked SQL Server database.

thanks for any help

raky
Aged Yak Warrior

767 Posts

Posted - 2009-01-23 : 11:04:49

select top 10 * from your table
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-23 : 11:13:40
show your query
Go to Top of Page
   

- Advertisement -