alexguz79 Posted July 6, 2010 Share Posted July 6, 2010 Greetings!!! I know if i want the SUM of al the values in a row i jus do 'SELECT SUM(row) AS row_total FROM table' but how about if i want to substract the values? ex: 2-2-3-1-4 what should i use? thanks Quote Link to comment Share on other sites More sharing options...
Mchl Posted July 6, 2010 Share Posted July 6, 2010 Add - in front? Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted July 6, 2010 Share Posted July 6, 2010 I think you woudl have to do this in PHP, doubt mysql has that feature - but why would you want to do this? anyway something like this after that query: $row_total = $row['row_total']; $inverted = 0 - $row_total; -cb- Quote Link to comment Share on other sites More sharing options...
alexguz79 Posted July 6, 2010 Author Share Posted July 6, 2010 thanks... i'll try that Quote Link to comment Share on other sites More sharing options...
Mchl Posted July 6, 2010 Share Posted July 6, 2010 I think you woudl have to do this in PHP, doubt mysql has that feature - but why would you want to do this? anyway something like this after that query: $row_total = $row['row_total']; $inverted = 0 - $row_total; -cb- How is that different from SELECT -SUM(row) AS row_total FROM table or SELECT SUM(-row) AS row_total FROM table or even $inverted = -$row_total; ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.