[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

SUM in one-to-many relationship

Posted on 2008-09-29
1
Medium Priority
?
188 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 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

656 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