Kai Lee
asked on
Running Sum Help
try using the COUNT and GROUPING functions is sql
start with the summing query type (sigma)
ASKER
I am sorry I am kind new to Access.
This is my sql looks like right now
SELECT Shifts.ShiftID, Shifts.[Tool Number], Shifts.ShiftEnd, Shifts.[Output_Tools/Shift ], Val(DSum("Tool Number","Shifts","Tool Number='" & [Tool Number] & "' And ShiftEnd <= #" & [ShiftEnd] & "#")) AS RunningSum
FROM Shifts
GROUP BY Shifts.ShiftID, Shifts.[Tool Number], Shifts.ShiftEnd, Shifts.[Output_Tools/Shift ];
This is my sql looks like right now
SELECT Shifts.ShiftID, Shifts.[Tool Number], Shifts.ShiftEnd, Shifts.[Output_Tools/Shift
FROM Shifts
GROUP BY Shifts.ShiftID, Shifts.[Tool Number], Shifts.ShiftEnd, Shifts.[Output_Tools/Shift
ASKER
I used Grouping. What is summing query type?
once you have the group by (which is different to your image above), you are on the right path.
do you want the count of each tool type? I dont really understand what you want.
also, if you upload the database I can look at the query
do you want the count of each tool type? I dont really understand what you want.
also, if you upload the database I can look at the query
it sounds like count of tools by day? i.e. grouped by date and tool number?
it also looks as if you are posting multiple threads for the same issue?
it also looks as if you are posting multiple threads for the same issue?
ASKER
lol I want to know if there is another way I can create a graph just in case this one doesn't work for me. But I really appreciate your help.
do you want the count of tools by day? please explain the requirement
once you have the query defined you can use Excel to create the graphs (if Access doesn't cut it)
using VAL( of tool numbers gives a very different result to COUNT
using VAL( of tool numbers gives a very different result to COUNT
ASKER
I want running sum of output by tool number and day.
i.e. SUM output GROUP BY tool number and day
SUM output assumes many output records for each tool?
SUM output assumes many output records for each tool?
ASKER
yes
so we are done?
ASKER
I want to know what cause the error
you didn't display the error.
you would use the SQL SUM function, not your own.
and you don't group by WHERE fields
Please upload the database.
you would use the SQL SUM function, not your own.
and you don't group by WHERE fields
Please upload the database.
ASKER
I have a BIG problem: I cannot design databases once I have logged onto https://www.experts-exchange.com because the SSL url clashes with Trusteer rapport and slows Access to a crawl.
So I cannot do both (design your databases and correspond on EE).
If no-one else can solve these issues then I will get a 2nd machine configured and look at the issues later
So I cannot do both (design your databases and correspond on EE).
If no-one else can solve these issues then I will get a 2nd machine configured and look at the issues later
ASKER
yea that is fine.
In the mean time it would be helpful if you explained exactly what you want in plain text.
e.g.
'I want to see the sum of 'output' for each shift and tool'
1. is the 'running sum' actually a running sum (accumulating as it goes) , or just the total of output grouped by toolnumber and shift ('day')?
2. does the same toolnumber occur many times in a shift?
3. does the exact same shiftend date occur for all tools in a day (is that why you are grouping by shift end?)? if the date/time varies you will get multiple shift- groups in a day
THE DATABASE YOU SENT HAS NO SHIFT TABLE OR RELATED FIELDS. I HAVE TO GO TO MEETINGS NOW, BUT WILL MONITOR EMAILS PERIODICALLY TO SEE IF YOU HAVE SUPPLIED THE CORRECT DATABASE AND ANSWERS TO THE QUESTIONS REGARDING ACTUAL REQUIREMENTS.
e.g.
'I want to see the sum of 'output' for each shift and tool'
1. is the 'running sum' actually a running sum (accumulating as it goes) , or just the total of output grouped by toolnumber and shift ('day')?
2. does the same toolnumber occur many times in a shift?
3. does the exact same shiftend date occur for all tools in a day (is that why you are grouping by shift end?)? if the date/time varies you will get multiple shift- groups in a day
THE DATABASE YOU SENT HAS NO SHIFT TABLE OR RELATED FIELDS. I HAVE TO GO TO MEETINGS NOW, BUT WILL MONITOR EMAILS PERIODICALLY TO SEE IF YOU HAVE SUPPLIED THE CORRECT DATABASE AND ANSWERS TO THE QUESTIONS REGARDING ACTUAL REQUIREMENTS.
ASKER
Just in case you don't know what a running sum means. A running total is the summation of a sequence of numbers which is updated each time a new number is added to the sequence, by adding the value of the new number to the previous running total.
i want to see the running total of output for each tool. I showed something similar in previous comment.
i want to see the running total of output for each tool. I showed something similar in previous comment.
ASKER
This is grouped by PLS and a running sum of percentage.
You haven't sent the database yet but the following is some sql for you to start with. You will need to substitute field names where mine are invalid.
SELECT Shift1.[Tool Number], Shift1.[Output], SUM(Shift2.[Output]) AS Running_Total
FROM Shift Shift1, Shift Shift2
WHERE Shift1.[Output] <= Shift2.[Output] or (Shift1.[Output]=Shift2.[O utput] and Shift1.[Tool Number] = Shift2.[Tool Number])
GROUP BY Shift1.[Tool Number], Shift1.[Output]
ORDER BY Shift1.[Output] DESC, Shift1.[Tool Number] DESC;
SELECT Shift1.[Tool Number], Shift1.[Output], SUM(Shift2.[Output]) AS Running_Total
FROM Shift Shift1, Shift Shift2
WHERE Shift1.[Output] <= Shift2.[Output] or (Shift1.[Output]=Shift2.[O
GROUP BY Shift1.[Tool Number], Shift1.[Output]
ORDER BY Shift1.[Output] DESC, Shift1.[Tool Number] DESC;
ASKER
I checked the database i sent. I am sure there is a shifts table and a running sum query. i will try this sql . Thanks.
ASKER
Why there are shift1 and shift2 two tables in sql? I only have one table. Can you take a look at the attachment that i posted in previous comments? I don't really understand this one.
as I have stated 3 times, your attachment contained no 'shift' table - I don't even know if this is the correct database.
see image below.
There are two shift tables needed in the query to generate the running totals. both are aliases of the original shift table. I have not tested the query because I don't have the table and data.
see image below.
There are two shift tables needed in the query to generate the running totals. both are aliases of the original shift table. I have not tested the query because I don't have the table and data.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you. I know how you did it. That is pretty clever.
ASKER