?
Solved

Multiply two SQL fields and SUM ?

Posted on 2006-11-30
1
Medium Priority
?
1,917 Views
Last Modified: 2012-06-21
Is it possible to multiple 2 SQL fields and then summarize them?

What I'm trying to do is calculate our top 100 spending customers. The fields I need to multiple are called qty * item_price.
Then I'm wanting to take those values and add up all the items by ID (which is the invoice ID ) and SUM them so that basically I can get a total value that each invoice has spent.

Is this  possible to write with SQL?
0
Comment
Question by:twentythree
1 Comment
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 600 total points
ID: 18050628
Hi twentythree,
Yes you can do it


SELECT InvoiceID, SUM (Qty*Item_price) as tot
FROM urTable
GROUP BY InvoiceID

Cheers!
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

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