faqts : Computers : Databases : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 15 people (40%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

How can I get a running total from three columns in a table? The sum of price - mycost * units_sold

Feb 20th, 2008 23:06
dman, Matt Chatterley, Tony Bland, http://sturly.com


You can do this by combining the mathematical operations into a SUM()
within the statement:
SELECT SUM((price - mycost) * units_sold) AS Total FROM Table1;