Results 1 to 2 of 2
Thread: Using SUM in a query
Nov 13, 2011, 11:01 #1
- Join Date
- Sep 2004
- Provo, UT
- 1 Post(s)
- 0 Thread(s)
Using SUM in a query
Every time a user upgrades to the paid membership a new row is inserted into the payments table. A monthly membership is $5.00, however, after fees from paypal, I actually get $4.55. The following query is correctly adding up all of the $5.00 payments but, of course, it's not really the dollar amount I end up with. What is the best way to tweak this query so that it takes $.45 off each payment before adding them all up?
SELECT sum(amount) as total FROM payments WHERE YEAR(payDate) = YEAR(CURDATE()) AND MONTH(payDate) = MONTH(CURDATE()) and uID in (select uID from users where subscription = 'Silver')
Thanks!Convert your dollars into silver coins. www.convert2silver.com
Nov 13, 2011, 11:08 #2Code:
SELECT sum(amount - 0.45) as total FROM payments WHERE YEAR(payDate) = YEAR(CURDATE()) AND MONTH(payDate) = MONTH(CURDATE()) AND uID IN (SELECT uID FROM users WHERE subscription = 'Silver')Guido - Community Team Leader
The Votes Are In: The Winners of the 2013 Community Awards are...
Blog - Free Flash Slideshow Widget