Saturday, 7 September 2013

mysql Math for Select Statements

mysql Math for Select Statements

I have a table structured the following way
table 1
------
userid
type
amount
Where type can be a deposit or withdrawal.
I'm looking to perform a query on this table where I can get the net
balance of sum of Withdrawals - Deposits for a given user.
Is this possible with mySQL, or do I need to run two separate queries and
perform the math in the code?

No comments:

Post a Comment