john33john33
Registered User.
- Local time
- Today, 14:10
- Joined
- Jul 23, 2015
- Messages
- 18
Table Motor
MotorID, MotorType, FuelType, Contact, Dept
AutoNum, word, word, word, word
Table MotorRecord
MotorID, RecordDate, Amount
AutoNum, Date, Num
Table MotorType
MotorType, FuelType, CO2
word, word, Num
This would show the desired data set.
And my intended outcome looks like:
It seems pivot is my option but i am not familiar with the function.
Any help would be appreciated.
MotorID, MotorType, FuelType, Contact, Dept
AutoNum, word, word, word, word
Table MotorRecord
MotorID, RecordDate, Amount
AutoNum, Date, Num
Table MotorType
MotorType, FuelType, CO2
word, word, Num
Code:
SELECT Motor.Dept & " " & Motor.MotorType & " " & Motor.FuelType AS Expr1, Sum(MotorRecord.Amount) AS [Amount], Sum(MotorRecord.Amount*MotorType.[CO2]) AS [CO2], Month(MotorRecord.RecordDate)
FROM MotorType INNER JOIN (Motor INNER JOIN MotorRecord ON Motor.MotorID = MotorRecord.MotorID) ON (MotorType.FuelType = Motor.FuelType) AND (MotorType.MotorType = Motor.MotorType)
WHERE (((MotorRecord.RecordDate) Between #7/1/2013# And #6/30/2014#))
GROUP BY Motor.Dept & " " & Motor.MotorType & " " & Motor.FuelType, Month(MotorRecord.RecordDate);
And my intended outcome looks like:

It seems pivot is my option but i am not familiar with the function.
Any help would be appreciated.