G
Guest
Why doesn’t my SQL work correctly?
I have a table tblEquipmentRotation with the following columns HistoryID,
LocationID, EquipmentID & Date_Installed. It keeps a running history of where
things have been.
When I run the Subquery:
(SELECT tblEquipmentRotation.EquipmentID,
Max(tblEquipmentRotation.Date_Installed) AS DateInsatlled
FROM tblEquipmentRotation
GROUP BY EquipmentID)
I get 262 records which is correct. But when I run the following query, with
the subquery in the FROM Clause I get all the record. Why?
SELECT b.LocationID, a.EquipmentID, a.DateInstalled
FROM tblEquipmentRotation AS b, [SELECT tblEquipmentRotation.EquipmentID,
Max(tblEquipmentRotation.Date_Installed) AS DateInstalled
FROM tblEquipmentRotation
GROUP BY EquipmentID]. AS a
WHERE ((.[EquipmentID]=[a].[EquipmentID]));
I have also tried running the subquery in the WHERE Clause but all it does
is shut down Access. Any Ideas it should be a text book query.
I have a table tblEquipmentRotation with the following columns HistoryID,
LocationID, EquipmentID & Date_Installed. It keeps a running history of where
things have been.
When I run the Subquery:
(SELECT tblEquipmentRotation.EquipmentID,
Max(tblEquipmentRotation.Date_Installed) AS DateInsatlled
FROM tblEquipmentRotation
GROUP BY EquipmentID)
I get 262 records which is correct. But when I run the following query, with
the subquery in the FROM Clause I get all the record. Why?
SELECT b.LocationID, a.EquipmentID, a.DateInstalled
FROM tblEquipmentRotation AS b, [SELECT tblEquipmentRotation.EquipmentID,
Max(tblEquipmentRotation.Date_Installed) AS DateInstalled
FROM tblEquipmentRotation
GROUP BY EquipmentID]. AS a
WHERE ((.[EquipmentID]=[a].[EquipmentID]));
I have also tried running the subquery in the WHERE Clause but all it does
is shut down Access. Any Ideas it should be a text book query.