>Here is a puzzle. I have a table that contains annual records for businesses. There may or may not be a record for a given business in any given year. So for BusinessA there may be records for 2000, 2003, 2004, 2008, 2010, 2012, etc. I want to SELECT the most recent 3 records. That is easy enough.
SELECT TOP 3 * FROM [HistoricalSummary] WHERE business=@business ORDER BY [year] desc
But now here's the problem. I want the order of these records to be sorted by year lowest to highest. So this is the opposite of what is needed to get the 3 latest records. Has anyone dealt with anything like this before?
>Thanks
SELECT *
FROM (SELECT TOP 3 * FROM [HistoricalSummary] WHERE business=@business ORDER BY [year] desc) Tbl1
ORDER BY Year
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.