Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Kotti
Posting Yak Master
129 Posts |
Posted - 2009-11-03 : 05:44:53
|
| Hello Friends,I have a table called Web_UserAccount where i saved the payment and Purchase details of User.Table FormatUAId UserId PurchaserId amount TransactionType1 1 0 100 12 2 0 200 13 1 4 50 24 2 1 30 25 1 0 80 36 1 0 40 47 1 3 20 2OutPut Structure:Here i am Passing (UserId=1 or PurchaserId=1 )in where condition to get the below expected result.Expected OutPut:UAId UserId PurchaserId amount TransactionType PStatus Balance1 1 0 100 1 Credit 100 3 1 4 50 2 Credit 1504 2 1 30 2 Debit 1205 1 0 80 3 Debit 406 1 0 40 4 Debit 0 7 1 3 20 2 Credit 20How i got the OutPut is?If the TransactionType=1 means i need the amount should be added in balance and PStatus should display as Credit If the TransactionType=2 and UserId=1 means i need the amount should be added in Balance and PStatus should display as CreditIf the TransactionType=2 and Purchaserid=1 means i need the amount should be subtracted in Balance and PStatus should display as DebitIf the TransactionType=3 means i need the amount should be subtracted in balance and PStatus should display as DebitIf the TransactionType=4 means i need the amount should be subtracted in balance and PStatus should display as Debit.If you need more explanation ,i will explain.Please anyone help me to get the query .Thanks in Advance. |
|
|
Kotti
Posting Yak Master
129 Posts |
Posted - 2009-11-03 : 08:28:25
|
| Hello Friends,Any one Please help me to get the correct query.Thanks in Advance |
 |
|
|
|
|
|