Combine Two Queries

crhodus

Registered User.
Local time
Today, 10:28
Joined
Mar 16, 2001
Messages
257
I'm having problems figuring out how to "Combine" two different queries.

I have the following two queries that I've written:

SELECT DISTINCT RecordType, InvoiceNumber, DeviceNumber, ChargeCode FROM tblDetail ORDER BY DeviceNumber, ChargeCode;

Select COUNT(CallDesc), SUM(TtlCallChgs) AS TotalUsageCharge FROM tblDetail Group By DeviceNumber;


How can I combine these two records that I get a count and a sum added to the first query.

Thanks,
CR Junk
 
I'm having problems figuring out how to "Combine" two different queries.

I have the following two queries that I've written:

SELECT DISTINCT RecordType, InvoiceNumber, DeviceNumber, ChargeCode FROM tblDetail ORDER BY DeviceNumber, ChargeCode;

Select COUNT(CallDesc), SUM(TtlCallChgs) AS TotalUsageCharge FROM tblDetail Group By DeviceNumber;


How can I combine these two records that I get a count and a sum added to the first query.
Not sure if you can. First, you might want to look at the FAQ I wrote on this: http://www.access-programmers.co.uk/forums/showthread.php?t=135763

You might not like what this does, but write this query SQL out and see if you can understand what it gives you:
Code:
SELECT (DISTINCT) RecordType, InvoiceNumber, DeviceNumber, 
   ChargeCode, COUNT(CallDesc), SUM(TtlCallChgs)

FROM tblDetail

GROUP BY RecordType, InvoiceNumber, DeviceNumber, ChargeCode

ORDER BY DeviceNumber, ChargeCode
You won't get groupings with this query by the Device Number alone, but you cannot do that here anyway. Refer to the FAQ to see why. Anyway, see what this can do for you.
 
Thanks for your help. When testing my query, I did not have my Group By correct.

Thanks again!
CR Junk
 

Users who are viewing this thread

Back
Top Bottom