This seems like an easy problem, but for the life of me I can’t get the solution. I’m trying to write a query that averages values by year. I think I’m on the right track by using the DatePart function, but I keep getting a compile error message. I have two tables with 2 & 3 fields respectively
tblA
A date
tblB
B A X
A and B are the primary keys (both are integers). date has format dd/mm/yy and x is a number
The query that I’ve created is as follows
SELECT DatePart('yyyy',[tblA].[date]) AS Expr1, Avg(tblB.X) AS AvgOfX
FROM tblA LEFT JOIN tblB ON tblA.A = tblB.A
GROUP BY DatePart('yyyy',[tblA].[date]);
Thanks in advance for the help,
Ed
tblA
A date
tblB
B A X
A and B are the primary keys (both are integers). date has format dd/mm/yy and x is a number
The query that I’ve created is as follows
SELECT DatePart('yyyy',[tblA].[date]) AS Expr1, Avg(tblB.X) AS AvgOfX
FROM tblA LEFT JOIN tblB ON tblA.A = tblB.A
GROUP BY DatePart('yyyy',[tblA].[date]);
Thanks in advance for the help,
Ed