sql server 2008 - SSRS Top N for Dates -
so writing ssrs report want calculate lead time based on arbitrary number deliveries. i have query in ssrs filter show last 5 deliveries. use top n filtering ssrs rightly complains number 5 not date. how filter last 5 latest dates without knowing exact dates of records returning? dataset follows (lead time calculation of order date less delivery date) order | del_date | lead_time ------|------------|----------- 00001 | 2015-05-01 | 20 00002 | 2015-01-08 | 21 00003 | 2015-02-05 | 22 00004 | 2015-03-11 | 26 00005 | 2015-01-21 | 8 00006 | 2015-04-12 | 12 00007 | 2015-03-02 | 12 00008 | 2015-02-01 | 12 the query should return order | del_date | lead_time ------|------------|----------- 00001 | 2015-05-01 | 20 00003 | 2015-02-05 | 22 00004 | 2015-03-11 | 26 00006 | 2015-04-12 | 12 00007 | 2015-03-02 | 12 thanks, can try this: select top 5 order, del_date, lead_time [table] ... order del_date desc