question

David 2 1 avatar image
David 2 1 asked

How To Select The Top Values From A Distinct List?

I have a table full of types of differing values however I only what to return the top 100 of these distinct values. In Oracle I used to use the rownum clause but how in SQL Server 2000 is this possible? I am looking for something like:

                    
select top 100 *                      
from (select distinct(col1)                    
from tab1)                    

Thanks in advance.

sql-server-2000aggregatestop
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
David 2 1 avatar image
David 2 1 answered

Got it to work with:

            
select top 100 type, count(*) from tab1              
group by type;            

Thanks anyway.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.