I'm always amazed at how many smart people are on here... Hopefully one of you have a minute to help me out...
I have a table with two UserIDs: DebitID and CreditID (think the perspective of your bank - debits to your account reduce your balance). The table also has an Amount field. The logged in user (authfield:UserID) may have sent (Debit) or received (Credit) an Amount. If they sent money, the DebitID field equals their UserID and User's ID to whom they sent the money would be identified in the CreditID field.
My challenge is I need the SQL statement to generate a "total balance" from all transactions where... Here's my JS kind of equivalent code.
var AccountBalance = 0;
if authfield:UserID == field:DebitID
AccountBalance = AccountBalance - Amount
else if authfield:UserID == field:CreditID
AccountBalance += Amount
I hope ^ is legible and one of you smart people out there can lend a hand. Thanks - Stuck!
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
ronbrumbarger
I'm always amazed at how many smart people are on here... Hopefully one of you have a minute to help me out...
I have a table with two UserIDs: DebitID and CreditID (think the perspective of your bank - debits to your account reduce your balance). The table also has an Amount field. The logged in user (authfield:UserID) may have sent (Debit) or received (Credit) an Amount. If they sent money, the DebitID field equals their UserID and User's ID to whom they sent the money would be identified in the CreditID field.
My challenge is I need the SQL statement to generate a "total balance" from all transactions where... Here's my JS kind of equivalent code.
var AccountBalance = 0;
if authfield:UserID == field:DebitID
AccountBalance = AccountBalance - Amount
else if authfield:UserID == field:CreditID
AccountBalance += Amount
I hope ^ is legible and one of you smart people out there can lend a hand. Thanks - Stuck!
Link to comment
Share on other sites
5 answers to this question
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.
Note: Your post will require moderator approval before it will be visible.