I need to generate a report for top 10 rows for each date in a table. I can write a statment for each date but can anyone help with writitng it in single query;
select top * from Table where date ='2014-01-01';
select top * from Table where date ='2014-02-01';
select top * from Table where date ='2014-03-01';
Looking for any help.
Br,
FK
Hi.
If you need TOP only for SAMPLING (whithout ORDER BY) you could try stratified sampling.
SELECT *
FROM TheTable
SAMPLE WHEN TheDate = '2014-01-01' THEN 10
WHEN TheDate = '2014-2-01' THEN 10
...
END;
HTH
Cheers.
Carlos.
Select * FROM Table Qualify Row_number()Over( partition by date order by column) between 1 and 10;
I think this should work..
Thanks Mani. It works. :)