G
Guest
I'm getting an error on this of "Datayype mismatch in criteria expression". What I understand of that message tells me that the field types don't match somewhere (my understanding is rather elementary... thanks for giving me another lesson!).
How can that be when it's referencing the same table? Can anyone help me on this one?
SELECT a.IDUniqueCarRecNo, Year(a.MaintDate), Month(a.MaintDate), MAX(a.OdometerRead) AS ThisMonth, MAX(b.OdometerRead) AS PreviousMonth
FROM tblMaintenanceRecord AS a LEFT JOIN tblMaintenanceRecord AS b
ON (DateSerial(Year(a.MaintDate),Month(a.MaintDate),1)=DateSerial(Year(b.MaintDate),1+Month(b.MaintDate),1))
AND (a.IDUniqueCarRecNo=b.IDUniqueCarRecNo)
GROUP BY a.IDUniqueCarRecNo, Year(a.MaintDate), Month(a.MaintDate);
How can that be when it's referencing the same table? Can anyone help me on this one?
SELECT a.IDUniqueCarRecNo, Year(a.MaintDate), Month(a.MaintDate), MAX(a.OdometerRead) AS ThisMonth, MAX(b.OdometerRead) AS PreviousMonth
FROM tblMaintenanceRecord AS a LEFT JOIN tblMaintenanceRecord AS b
ON (DateSerial(Year(a.MaintDate),Month(a.MaintDate),1)=DateSerial(Year(b.MaintDate),1+Month(b.MaintDate),1))
AND (a.IDUniqueCarRecNo=b.IDUniqueCarRecNo)
GROUP BY a.IDUniqueCarRecNo, Year(a.MaintDate), Month(a.MaintDate);