473,499 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sum values in Query

365 Contributor
Hello, i am need to sum some data as so..

StaffID, RequestID, MinutesUsed

StaffID limited by combobox on form,
requestID (contains a duplicate numbers reletive to the point the record is created e.g. 10 records added contain "1" next time the procedure (for that staff) is records will be "2"),
Minutes used is what i want to sum and i want to sum by limiting the sum to the highest RecordID ( it sums all entries when i do it)

eg
StaffID requestID MinutesUsed
1 1 100
1 1 150
1 1 200
1 2 100
1 2 200
1 3 100

Make sense??

i would prefer a dlookup so that i can use the value in VBA or
ideally i want this to be an update query but that removed the sum field.
ive tried dsum and dlast and other function but it doesnt seem to acheive what i want.

thanks and i will probly kick my self cos its so easy
Nov 30 '07 #1
1 1369
puppydogbuddy
1,923 Recognized Expert Top Contributor
Hello, i am need to sum some data as so..

StaffID, RequestID, MinutesUsed

StaffID limited by combobox on form,
requestID (contains a duplicate numbers reletive to the point the record is created e.g. 10 records added contain "1" next time the procedure (for that staff) is records will be "2"),
Minutes used is what i want to sum and i want to sum by limiting the sum to the highest RecordID ( it sums all entries when i do it)

eg
StaffID requestID MinutesUsed
1 1 100
1 1 150
1 1 200
1 2 100
1 2 200
1 3 100

Make sense??

i would prefer a dlookup so that i can use the value in VBA or
ideally i want this to be an update query but that removed the sum field.
ive tried dsum and dlast and other function but it doesnt seem to acheive what i want.

thanks and i will probly kick my self cos its so easy
I am not sure what you want, but try this:

SELECT a.StaffID, a.RequestID, Sum(a.MinutesUsed)
FROM TableX AS a
GROUP BY a.StaffID, a.RequestID
HAVING a.RequestID =
(SELECT max(RequestID)
FROM TableX As b
WHERE b.StaffID = a.StaffID
)
Dec 1 '07 #2

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

Similar topics

2
12383
by: Wilder | last post by:
I'm trying to update a field in one table with the minimum values of the field in another table. The two tables are linked via a common field. I want to populate a date field in one table with...
3
7536
by: MX1 | last post by:
I'm ready to pull the hair out of my head. I have a query with a couple of parameters that I want to get from combo boxes on a form. One parameter is a date with a dynamically calculated year and...
2
10042
by: Todd D. Levy | last post by:
I have a table of Country names & Country codes in alphabetical order. This is a lookup table that a number of other tables use to populate the Country field via a drop down Combo Box on the...
3
3998
by: JOEP | last post by:
What do I need to do to allow an append query to post null values to records in a field of the destination table? Basically I want to allow records with null values to post to the table. The append...
19
59880
by: bdt513 | last post by:
I am trying to extract the values from a query using VBA. Specifically, I want to concatenate all the values of the "rosEmail" field from query "qselRosterEmailList" into one string (strEmails). I...
2
2282
by: Keith | last post by:
Good Afternoon, New to .Net. I am trying to pass date/time values to a MS Access query depending on what value is selected from a dropdown list box (January, February, etc). I have declared...
3
1532
by: robboll | last post by:
I am building an ASP.NET data entry form and when I change the values per the dropdowns and click "save", the old values remain. Are there any suggestions on how to update the variables to the...
4
1478
by: Juan Jose Costello Levien | last post by:
Hello, I am writing my first trigger in C for PostgreSQL. It compiles Ok, and added it to the database using CREATE TRIGGER. But when I try to fire it, psql simply says 'The connection was lost"....
2
14691
by: Zlatko Matić | last post by:
Hello. How to reference selected values from a multi-select list box, as a criteria in a query ? Is it possible at all? Regards, Zlatko
7
1750
by: sparks | last post by:
I am working on a database that has a lot of calculated values on the forms. These were never put into the tables. But were tied to unbound fields on the forms. Now 8000 records later they want...
0
7134
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
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7229
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...
0
5485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.