?
Solved

SUM in one-to-many relationship

Posted on 2008-09-29
1
Medium Priority
?
190 Views
Last Modified: 2011-09-20
Say I have two tables:

tblCustomer and tblPurchases
a single customer can purchase many items from the store.
If I do a regular query, the customer's name is repeated for each purchase made.

Instead I would like a TOTAL of all their purchases (Quantity) for each customer.

So a list of all the customers, and the total amount each customer has purchased.
0
Comment
Question by:NO_CARRIER
1 Comment
 
LVL 43

Accepted Solution

by:
TimCottee earned 300 total points
ID: 22595916
Hello NO_CARRIER,

Select tblCustomer.NameColumn, Sum(tblPurchases.ValueCOlumn) From tblCustomer Inner Join tblPurchases On tblCustomer.KeyColumn = tblPurchases.KeyColumn

You will need to specify the correct column names of course.

Regards,

TimCottee
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question