If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#21
|
|||
|
|||
Query to add totals
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 "jenksonu via AccessMonster.com" wrote: 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 Hookom wrote: 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; I still can't seen to get this to work. Still getting Syntax error (Missing Operator) [quoted text clipped - 28 lines] each Month Thanks in advance for your help -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...eries/200907/1 |
Thread Tools | |
Display Modes | |
|
|