Cosmos75
Registered User.
- Local time
- Yesterday, 21:52
- Joined
- Apr 22, 2002
- Messages
- 1,281
I have a product table (tblProducts) and a usage table (tblUsage).
tblProducts
- ProductID (PK)
- Product (Text)
tblUsage
- UsageID (PK)
- ProductID (FK)
- UsageDate (Date)
- UsageAmount (Number)
I would like to have a query that shows me what the Maximum usage for all products in a given year AND also the date of the returned usage.
So I have a query that has this
I have also set the criteria for YEAR as 2002 (via a textbox in a form).
This works fine to show me the maximum usage for each individual product in 2002, but how do I show the UsageDate for MaxOfUsage??
What happens if there are two (or more) UsageDate(s)/with the same UsageAmount = MaxOfUsage?
tblProducts
- ProductID (PK)
- Product (Text)
tblUsage
- UsageID (PK)
- ProductID (FK)
- UsageDate (Date)
- UsageAmount (Number)
I would like to have a query that shows me what the Maximum usage for all products in a given year AND also the date of the returned usage.
So I have a query that has this
PHP:
SELECT tblProducts.ProductID,
Year([UsageDate]) AS [YEAR],
Max(tblUsage.UsageAmount) AS MaxOfUsage
I have also set the criteria for YEAR as 2002 (via a textbox in a form).
This works fine to show me the maximum usage for each individual product in 2002, but how do I show the UsageDate for MaxOfUsage??
What happens if there are two (or more) UsageDate(s)/with the same UsageAmount = MaxOfUsage?
Last edited: