D
Duane Hookom
You need to understand how to create queries and use various expressions. You
can create queries with LEFT or RIGHT JOINs that include all the records from
one table and matching from the other.
--
Duane Hookom
Microsoft Access MVP
can create queries with LEFT or RIGHT JOINs that include all the records from
one table and matching from the other.
--
Duane Hookom
Microsoft Access MVP
jenksonu via AccessMonster.com said:This still doesn't seem to work... So I back tracked in our conversation and
changed the YTD code you gave me to look like this.
SELECT [EmployeeName], Sum([HoursWorked]) AS MTD
FROM test
WHERE Month(TheDate)=Month(Date())
GROUP BY [EmployeeName];
Then I did a new query that joined the MTD and YTD that looks like this
SELECT MTD.EmployeeName, MTD.MTD, YTD_2009.YTD_2009
FROM MTD INNER JOIN YTD_2009 ON MTD.EmployeeName = YTD_2009.EmployeeName;
This seems to work for what I need.
One question, I have noted that if there is no data for this month, then this
query MTD and YTD shows no user names and or YTD Information. Is there a way
to make MTD show all 0 if no entry's for the current month?
Duane said:Try:
SELECT EmployeeName,
Sum(HoursWorked * Abs(Format(TheDate,"yyyymm") =
Format(Date(),"yyyymm"))) as MTD,
Sum(HoursWorked * Abs(Year(TheDate) = Year(Date())) ) as YTD
FROM testQuery
GROUP BY EmployeeName;
[quoted text clipped - 28 lines]I still can't seen to get this to work. Still getting Syntax error (Missing
Operator)each Month
Thanks in advance for your help