I’m trying to develop a SP for Transaction operation , The SP gets as parameters the Username of the player , The Transaction amount, and the Type of the Transaction if it’s Deposit / Draw .
My problem is when the first row enters to the table my TotalAmount column in the tables the sums the total amount by Username starts from NULL for each username instead of the first deposit . From the second row to the same username it’s sums the total amount fine .
The SP – https://i.stack.imgur.com/8RmW2.png
The Problem – https://i.stack.imgur.com/NYTSx.png
Thanks!
Advertisement
Answer
You have code like this :
SET @TotalAMT = (@TransactionAMT + ( ... some code here))
Change it like this
SET @TotalAMT = (@TransactionAMT + COALESCE( ... some code here), 0)