davidd31415
Programmer
Hi,
I have a query that uses the SUM function and I'm wondering if there's a way that I can display more than one field that isn't summed? I get an error since the field is not calculated in the aggregate function.
I'll try to clarify...
I have a Transactions table that has the following information in it:
Test_Request_Number, Employee_Name, Regular_Hours, Overtime_Hours, Total_Hours
I currently have a query that looks like this:
Request Number Reg. Hrs Overtime Hrs Total Hrs
test request #1 x x x
test request #2 x x x
and so on...
The test request number comes from a TestRequests table. The TestRequests table also has a field called ProgramID which references records in the Programs table. The Programs table has a field called ProgamName.
What I would like to do is have the query also show the ProgramName for each test request. Although the Transactions table has many entries, each test request is always related to only one ProgramID. The final query should look like this:
Request Number Prg Name Reg. Hrs Overtime Hrs Total Hrs
test request #1 Prg a x x x
test request #2 Prg b x x x
If it helps in answering, here is the SQL I am using for the query I do have working right now:
SELECT [TestRequests.TestRequestNumber] AS [Test Request Number], Sum([Transactions].[Hours]) AS [Total Regular Hours], Sum([Transactions].[OvertimeHours]) AS [Total Overtime Hours], Sum([Transactions].[Hours]+[Transactions].[OvertimeHours]) AS [Total Hours]
FROM TestRequests, Transactions
WHERE ((([TestRequests].[TestRequestID])=[Transactions].[TestRequestID]) And Not [TestRequests].[TestRequestNumber]='N/A')
GROUP BY [TestRequests].[TestRequestNumber]
ORDER BY [TestRequests].[TestRequestNumber];
Thanks for any assistance,
David
I have a query that uses the SUM function and I'm wondering if there's a way that I can display more than one field that isn't summed? I get an error since the field is not calculated in the aggregate function.
I'll try to clarify...
I have a Transactions table that has the following information in it:
Test_Request_Number, Employee_Name, Regular_Hours, Overtime_Hours, Total_Hours
I currently have a query that looks like this:
Request Number Reg. Hrs Overtime Hrs Total Hrs
test request #1 x x x
test request #2 x x x
and so on...
The test request number comes from a TestRequests table. The TestRequests table also has a field called ProgramID which references records in the Programs table. The Programs table has a field called ProgamName.
What I would like to do is have the query also show the ProgramName for each test request. Although the Transactions table has many entries, each test request is always related to only one ProgramID. The final query should look like this:
Request Number Prg Name Reg. Hrs Overtime Hrs Total Hrs
test request #1 Prg a x x x
test request #2 Prg b x x x
If it helps in answering, here is the SQL I am using for the query I do have working right now:
SELECT [TestRequests.TestRequestNumber] AS [Test Request Number], Sum([Transactions].[Hours]) AS [Total Regular Hours], Sum([Transactions].[OvertimeHours]) AS [Total Overtime Hours], Sum([Transactions].[Hours]+[Transactions].[OvertimeHours]) AS [Total Hours]
FROM TestRequests, Transactions
WHERE ((([TestRequests].[TestRequestID])=[Transactions].[TestRequestID]) And Not [TestRequests].[TestRequestNumber]='N/A')
GROUP BY [TestRequests].[TestRequestNumber]
ORDER BY [TestRequests].[TestRequestNumber];
Thanks for any assistance,
David