Creating a reuseable report

A

Anjali

I have used query #1 & #2 to create a combined query (#3)-
see below - to create a report which will list the system
name ordered by total avg. weekly analyst support hours in
descending order. Within each system grouping, the systems
analyst name is listed in alphabetical order with their
corresponding avg. weekly support hours. I want to make
this report reusable to display the correct information,
in the correct order, for whatever date range that the
user enters when prompted.
Currently, I can't get the correct information to print
out if I use varying dates.

1)

SELECT System1.SystemName, Analyst1.AnalystFName,
Analyst1.AnalystLName, AnalystSupport1.SupportHours,
AnalystSupport1.TransDate
FROM System1 INNER JOIN (Analyst1 INNER JOIN
AnalystSupport1 ON Analyst1.AnalystFName =
AnalystSupport1.AnalystFName) ON System1.SystemName =
AnalystSupport1.SystemName
WHERE (((AnalystSupport1.TransDate) Between [Type a
beginning date (9/99/9999):] And [Type an ending date
(9/99/9999):]))
GROUP BY System1.SystemName, Analyst1.AnalystFName,
Analyst1.AnalystLName, AnalystSupport1.SupportHours,
AnalystSupport1.TransDate;

2)

SELECT System1.SystemName, Sum
(AnalystSupport1.SupportHours) AS SumOfSupportHours,
AnalystSupport1.TransDate
FROM System1 INNER JOIN AnalystSupport1 ON
System1.SystemName = AnalystSupport1.SystemName
GROUP BY System1.SystemName, AnalystSupport1.TransDate
ORDER BY Sum(AnalystSupport1.SupportHours) DESC;

3)
SELECT Query1.SystemName, SystemQuery1.AnalystFName,
SystemQuery1.AnalystLName, SystemQuery1.SupportHours,
Query1.SumOfSupportHours
FROM Query1 LEFT JOIN SystemQuery1 ON Query1.SystemName =
SystemQuery1.SystemName
GROUP BY Query1.SystemName, SystemQuery1.AnalystFName,
SystemQuery1.AnalystLName, SystemQuery1.SupportHours,
Query1.SumOfSupportHours
ORDER BY Query1.SumOfSupportHours DESC;
 
Top