TheresAlwaysAWay
Programmer
I HATE it when something that should be easy turns into a can of worms!
I have two tables, AllVehicles and Dealers. Both have a common field, DealerID, which is the PK of Dealers table and just a simple data field on AllVehicles. I have a field in the Dealers table, 1stQuote, which is designed to hold the date that the first quote for one of that dealer's customers was entered into the DB. The date of interest is found in [AllVehicles].[QTDate].
That field has been in place for quite a while but the coding that was intended to populate it as the first quote was being written was weak and didn't always get it right. I've corrected those errors, and now I want to run an update query on the Dealers table that makes this value =Min([QTDate]) for every dealer in the DB. I have the two tables joined where equal on the DealerID field, but can not get it to perform as expected. I get messages such as "you tried to execute a query that does not include *expression* as part of an aggregate function" and others, depending on how I've configured my misguided attempts.
This must be do-able but I'm clearly missing it. Here's current failing SQL.
UPDATE AllVehicles INNER JOIN Dealers ON AllVehicles.DealerID = Dealers.DealerID SET Dealers.[1stQuote] = Min([QTDate]);
I know one of the wizards out there will probably be laughing at my ignorance, but I don't mind as long as you can point me in the right direction!
As always, thanks in advance.
I have two tables, AllVehicles and Dealers. Both have a common field, DealerID, which is the PK of Dealers table and just a simple data field on AllVehicles. I have a field in the Dealers table, 1stQuote, which is designed to hold the date that the first quote for one of that dealer's customers was entered into the DB. The date of interest is found in [AllVehicles].[QTDate].
That field has been in place for quite a while but the coding that was intended to populate it as the first quote was being written was weak and didn't always get it right. I've corrected those errors, and now I want to run an update query on the Dealers table that makes this value =Min([QTDate]) for every dealer in the DB. I have the two tables joined where equal on the DealerID field, but can not get it to perform as expected. I get messages such as "you tried to execute a query that does not include *expression* as part of an aggregate function" and others, depending on how I've configured my misguided attempts.
This must be do-able but I'm clearly missing it. Here's current failing SQL.
UPDATE AllVehicles INNER JOIN Dealers ON AllVehicles.DealerID = Dealers.DealerID SET Dealers.[1stQuote] = Min([QTDate]);
I know one of the wizards out there will probably be laughing at my ignorance, but I don't mind as long as you can point me in the right direction!
As always, thanks in advance.