473,387 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do I subtotal and grand total in a query?

Hello,

I am trying to build a query that subtotals the amount of hours worked and earnings made per pay period for each employee. I built a Payroll table with employee name, start time, end time, lunch in, lunch out, hourly rate and added these fields to my query to form new fields with expressions to calculate the total hours worked per day (end time- start time) and the earnings made per day (total hours worked per day x hourly rate)and now I would like to subtotal the hours worked and earnings made per payperiod for each employee.

I put the criteria for the date field between #1/30/2012#and#2/5/2012#, which is the pay period I want to look at, and I tried grouping the sum of my new field expressions (hours worked per day, earnings made per day) and when I try to run the query summing both expressions, a message pops up saying, "subqueries cannot be used in the expression ([total hours]*[hourly rate])". When I try grouping the sum of one expression, for example the earnings made per day expression field, a message pops up saying, "you need to execute a query that does not include the specified expression '([end time]-[start time])'".

How do I subtotal and grand total my hours and earnings for each employee for the specified date range?
Mar 16 '12 #1

✓ answered by Rabbit

You don't do subtotals and grand totals in a query, you do it in the report.

5 20793
Rabbit
12,516 Expert Mod 8TB
You don't do subtotals and grand totals in a query, you do it in the report.
Mar 16 '12 #2
Thank you Rabbit. I will do that.
Mar 19 '12 #3
hvsummer
215 128KB
@Chelle8263: Actually Rabbit is not correct, you can have subtotal in Query.
Using GroupBy/Total Query like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT Group, SubGroup, Sum(Qty) as MTD
  2. FROM Table1
  3. GROUP BY Group, SubGroup
  4. ORDER BY Group, SubGroup
  5. UNION ALL
  6. SELECT Group, "Total "&Group as SubGroup, Sum(Qty) as MTD
  7. FROM Table1
  8. GROUP BY Group
  9. ORDER BY Group, SubGroup;
  10.  
Nov 23 '15 #4
Rabbit
12,516 Expert Mod 8TB
@hvsummer, I didn't say you couldn't. Rather, I said you don't. The implication being that it's better to handle subtotals and grand totals on the reporting end rather than using a work around solution on the querying side.
Nov 23 '15 #5
NeoPa
32,556 Expert Mod 16PB
@HVSummer.
Rabbit is quite right here.

Please consider, when offering advice, the sense of that advice. Inexperienced people new to Access often ask for things that are not good for them. It is our responsibility as experts to consider this before simply offering answers. There are many things that we know how to do, yet would never offer as advice without a strong warning against using such an approach. It is irresponsible to do otherwise.

If, after some responsible direction from an expert, the OP still requires direction to go a way that they have been warned against, then that's fine. We aren't baby-sitters. Nevertheless we do have a responsibility to give sensible advice where we can. Bad advice is generally worse than no advice at all, so care and consideration must always be shown.
Nov 24 '15 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: CSDunn | last post by:
Hello, I have 14 fields on a report that hold integer values. The field names use the following naming convention: T1Number, T2Number ....T14Number. I need to get a 'sub total' of all fields as...
5
by: simondsm | last post by:
I have a video tape library that we use at work here in a MS-Access database. When originally desgined, we never thought ot convert the time on the fly into total seconds, but instead, we stored...
17
by: barkarlo | last post by:
I need help to make grand total time in continuous forms. to calculate total work time I use following formula =format(+1--nz();"short time"). but when I make grand total time in form footer (for...
5
by: mebrabham | last post by:
Hello, I am trying to create a running subtotal in a query and then graph the running subtotal for each city group. The data looks like this in the table (for illustration): My City My...
0
by: jessicaeatworld | last post by:
Hi, I'm using Access 2003 on Windows XP. I have created a PivotTable View Form and at the bottom is an automatically inserted Grand Total row. I added sum and avg fields and then hid the details so...
0
by: Alagas | last post by:
Hi, I'm new to access 2003 & would like to know how to create a report that shows the grand total of counts, details are as the following: 1) I've a database of credit cards where I would like to...
3
by: kkshansid | last post by:
how to get grand total of two years 2001,2002 are fields SELECT sum( 2001 ) AS "2001-2002", sum( 2002 ) AS "2002-2003", ( "2001-2002" + "2002-2003" ) AS "grand total" FROM school this query...
3
by: monstez88 | last post by:
Hi, I'm trying to create a Invoice form with javascript. Basically, my invoice form should have the field item, cost, quantity and product total. It shd have a function to allow the user to add...
4
by: shalskedar | last post by:
In my Database 1 of the Report i need to find the grand total for a field which is inherited from the 1 of the subform.. Ex-The report field control source property is set to as =!Text1693 ...
2
by: GLEberts | last post by:
I am trying to calculate a Grand Total in a continuous form. This question has probably been beaten to death but I could not find any answers or solutions on how to solve. I am trying to stay away...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.