I am trying to produce an SQL select statement that will extract the highest date value for each category.
The attached image best demonstrates the desired output.
There are more categories in the production system although I am only interested in a subset. Equally there are millions of records in the TblActions table. The highest ActionID of each value against each company could be used to determine the most recent as the DateOfAction is not updated and is created at the time of the record being inserted. This may be a faster route for determining the result.
At the moment I use multiple joins, one for each action I seek. I have found this to be quite sluggish, even with indexes. Can you please recommend an approach that would best facilitate getting the desired result. I am using SQL 2000 at the moment so need an SQL 2000 compatible solution although this is in migration to SQL 2012 so I would certainly be interested in hearing about any methods that would make this faster in newer versions if there are any.
I have also attached the spreadsheet for copying/pasting if needed.
Thank you so much!