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 2000 Forums
 SQL Server Development (2000)
 Returning top values of a given column

Author  Topic 

KidSQL
Yak Posting Veteran

88 Posts

Posted - 2005-04-14 : 15:59:28
I've got a table with the following columns

Date Item Value
Jan-96 abc 4
Jan-96 def 3
Jan-96 xyz 5
Feb-96 (etc)

with historical records of values per Item on a monthly basis. Can anyone tell me how I would return, say, the top 1000 values per month from this table?

Thanks in advance to anyone wiling to help.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-04-14 : 16:58:03
How about this?


select [date]
,[value]
from myTable a
Where value in
(
select top 1000 value
from myTable
where [date] = a.[date]
order by value desc
)


Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -