|
-
Feb 16th, 2012, 05:32 PM
#1
Thread Starter
Hyperactive Member
(Access 2007) Running a Parameter Query Several Times at Once
Hello all,
I have a Parameter Query in Access that retrieves the most recent records for each PartID up to a particular date. So, as an example, there may be a record with the PartID number 100 in uploads 1, 2 and 3, and the query will retrieve the 3rd example so long as the parameter is >3. If the parameter is set to 2, it will retrieve the second example, and so on.
This allows me to retrieve a accurate 'snapshot' of the most recent data, as it was at any point in time during the project.
Naturally, this isn't enough. My customer now wants a historical graph of this data: so I need to build a query that sums the Count for each snapshot and compiles them into a format a graph can support.
Intuitively, the simplest way to do that is to run the existing query as many times as there are upload numbers: take the sums each time and put them into a new row. But I'm really not sure how to achieve this within Access.
Any help would be appreciated. I'll let you know if I manage to solve it on my own first.
Thanks,
Qu
(Edit) Here's the Historical Snapshot SQL Query just in case you find it useful, though I'm not sure how relevant it is to my question:
Code:
SELECT [HistoricalStatus].*
FROM [HistoricalStatus]
INNER JOIN
(
SELECT [HistoricalStatus].[Part ID] AS MaxPartID, Max([HistoricalStatus].[Upload #]) AS MaxUploadNum
FROM [HistoricalStatus]
WHERE [HistoricalStatus].[Upload #] < maxUploadNumber
GROUP BY [HistoricalStatus].[Part ID])MAXUpload
ON MAXUpload.MaxPartID = [HistoricalStatus].[Part ID] AND MAXUpload.MaxUploadNum = [HistoricalStatus].[Upload #]
WHERE ((([HistoricalStatus].[Part ID])=[MAXUpload].[MaxPartID]) AND (([HistoricalStatus].[Upload #])=[MAXUpload].[MaxUploadNum]))
UNION SELECT [HistoricalStatus].*
FROM [HistoricalStatus]
WHERE [HistoricalStatus].[Upload #] = maxUploadNumber;
Last edited by Quasar6; Feb 16th, 2012 at 05:52 PM.
Reason: Added Code
"Why do all my attempts at science end with me getting punched by batman?" xkcd.
| Pong| |
Sorry for not posting more often.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|