Solved

Multiply two SQL fields and SUM ?

Posted on 2006-11-30
1
1,886 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 150 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

808 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