A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Query to add totals



 
 
Thread Tools Display Modes
  #21  
Old July 7th, 2009, 04:11 AM posted to microsoft.public.access.queries
Duane Hookom
external usenet poster
 
Posts: 7,177
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:47 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.