473,624 Members | 2,160 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 1393
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.MinutesUs ed)
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
12389
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 the earliest date in another table where the linking fields values are equal. I set up a query with the two tables, made sure the common fields were linked, set the query as an "update" query, placed the field and table I want to update in the...
3
7544
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 the other is criteria for a Yes or No field. I'll focus on the Yes/No field for simplicity. If I run the query with the criteria hard coded as either "YES" or "NO", it works. In the values of the combo box in my form, I have it set as...
2
10050
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 form(s) for the table(s) in question. The "United States" Country name & the "US" Country code are selected 99% of the time. I would like to have the "United States" & "US" be the default values
3
4009
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 query will not work unless there are values in the data i am attempting to send. I want the fields in the destination table to accept null and populated values. Any help here would be gladly accepted. thanks
19
59950
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 can get one record's result by using the DLookup fuction, of course, but I want to get every record's value. To do this, I believe I need to build a recordset, but I do not know how. I've read about doing it using DAO in Access 97, but I am...
2
2291
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 those values as date datatypes and assigned their values with the # signs in front and back. When I click the submit I get the following error message: Data type mismatch in criteria expression cmdSelect1 = New OleDbCommand("Select Count(*) from ...
3
1537
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 latest data selections? ***** The code: ******************************************* Imports System.Data.SqlClient Public Class WebForm1
4
1489
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". What I don't know is how to get the row values (not the name fields) from tg_trigger. The code is: .... TriggerData *trigdata = (TriggerData *) fcinfo->context;
2
14731
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
1759
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 these values in the tables. All of this is done in modules after update of certain values entered on the forms. The calculations are called on current of the forms so they are recalculated each time the form is opened. I have no idea why it was...
0
8173
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8679
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8621
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8475
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6110
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5563
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2606
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 we have to send another system
1
1785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.