Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Joining a Total and Detail query 1

Status
Not open for further replies.

bjt52

Technical User
Sep 1, 2004
37
0
0
US
I have a query that totals items by the customer_account and another that has all the items. What I need to do is join these 2 queries together so that the total is at the top or bottom of the detail. I tied to use a union query but I only have 2 fields in the Total query and 15 in the detail. Is there are way to get the two together?
Thanks
 
Try something like that:

SELECT CUSTOMER, A,B,C,D,…,TOTAL_BY_PRODUCT
FROM THE_TABLE
UNION ALL
SELECT CUSTOMER, “” AS A, “” AS B, “” AS C, “” AS D, …. , TOTAL_BY_CUST
FROM
( SELECT CUSTOMER, SUM ( THE_FEILD) AS TOTAL BY_CUST
FROM THE_TABLE
GROUP BY CUSTOMER) AS w

[/COLOR BLUE]


Jean-Paul
Montreal
To send me E-Mail, remove “USELESSCODE”.
jp@USELESSCODEsolutionsvba.com
 
Thanks, glad I could help.

Jean-Paul
Montreal
To send me E-Mail, remove “USELESSCODE”.
jp@USELESSCODEsolutionsvba.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top