View Full Version : Nested Aggregate Query?


dsmythe
09-03-2009, 01:51 PM
I have an Access table with 3 columns:

partnumber, datereceived, qtyreceived.

To explain, on a regular basis suppliers submit lists of part numbers and "quantities available to purchase" which are appended to a table.

The suppliers submit the same part numbers each time with different quantities.

I am trying to query an output equal to:

Partnumber, the number of times the part number was received, the last date the part was received (max date), the qty that was received on last date.

I can do this in Access with two queries... but I cannot seem to sort through all of the examples I've found to get the right form to create this in one query.

I've lurked here for some time finding solutions to my issues. Thanks in advance for all your help!

pbaldy
09-03-2009, 02:12 PM
Personally I'd just leave it as a 2 query solution. If you really want it as one query, you'd join on a subquery instead of the second query:

...INNER JOIN (SELECT ...) AS qryMaxDates ON...

Instead of:

...INNER JOIN qryMaxDates ON...