Solved

Multiply two SQL fields and SUM ?

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now