i have a db with records with date (timestamp) i need to select 10 records for each day (there are many more per day) and order them by few columns...
how should that qu
To select the top 10 records for each day ordered by days in SQL Server 2005
select * from
(select *,ROW_NUMBER()
OVER
(PARTITION BY record.day order by record.day desc,record.score desc)
as row from record)
as table1 where row < 11
Now since your record table doesn´t have a day column as such, you need to use something like datepart(day, record.date)
instead of record.day
This should solve your problem