Environment: MS SQL 2005 back end. Choice of front ends: Excel 2007, Crystal Report 2008, Forest & Trees, and SharePoint 2007
I am trying to create a report each month which shows a line graph comparing the count of tickets resolved by an analyst with their 12 month simple moving average (SMA) and against the SMA for their group and also the enterprise as a whole (all analysts). A report user should be able to select a group (e.g. Tier 1) and then select a member of that group (analyst) and run the report. I have attached a screen shot showing the results in Forest & Trees (F&T). I don't like this interface and will create a new front end with Excel or equivilent, but that is another question...
Even though it is ugly, I can get the data. I am using several queries cobbled from another legacy report. Here's the process: The first query calculates the overall SMA for the last 12 months, and then another query calculates the SMA for the group. Finally, another query calculates the actual ticket count and SMA for the analyst. The first 2 queries take about 30 seconds each, but the query for the analyst takes 5 minutes for each analyst. This would take 6 days to run as is.
My thinking is that the queries only run once a month and could be stored in new tables. There would be separate tables for the overall and group SMAs. The analyst totals have to be calculated separately after the group is selected because an analyst can belong to more than one group. After the tables are generated the first time, then each following month it only has to add the just completed month to the previous calculation.
For the purposes of awarding points, I will be breaking the question into several parts. I have attached excepts of the tables invloved as well as my queries.
Today's question: Please review my current queries and recommend performance improvements.