Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 7th, 2006, 12:17 PM
Registered User
 
Join Date: Apr 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default QUERY SUBTOTAL

in a many to one relationship, how can i get a subtotal of values from the many side over to the related record on the one side, in a query
 
Old November 8th, 2006, 09:20 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

If, for example, you have one customer, with many orders, and you want to total the order amounts for the one customer, you would do this:

SELECT tblCustomer.CustomerName, Sum(tblOrder.OrderAmount) AS SumOfOrderAmount
FROM tblCustomer INNER JOIN tblOrder ON tblCustomer.CustomerID = tblOrder.CustomerID
GROUP BY tblCustomer.CustomerName;

If you were making this in the query designer, select your tables, make sure there is a relationship, the select your columns, then select View > Totals, and then in your value column, select Sum.

Does that help?


mmcdonal
 
Old November 8th, 2006, 11:59 AM
Registered User
 
Join Date: Apr 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

YES, THAT'S PERFECT. THANKS.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Subtotal fields jsims Access 1 November 10th, 2008 11:34 AM
Subtotal yogeshyl SQL Language 1 July 15th, 2008 02:16 PM
Multilevel subtotal of columns yogeshyl SQL Language 1 July 15th, 2008 02:12 PM
percent of subtotal mtlpp Excel VBA 0 May 14th, 2005 10:09 AM
SubTotal Field geoffeg BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 September 23rd, 2004 06:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.