Solved

SUM in one-to-many relationship

Posted on 2008-09-29
1
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 43

Accepted Solution

by:
TimCottee earned 75 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

707 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