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 |
|
esambath
Yak Posting Veteran
89 Posts |
Posted - 2009-04-29 : 06:09:55
|
| Hi guys,Please help this queryI have two table LP_UserManagement and LP_PaymentLP_UserManagement UserId Email Username Password UserType(0=Admin,1=User,2=Expert)LP_PaymentPaymentId,UserId,ExpertId,TxnId,PaymentMethod,Email,Pricesample datasUserId Email Username Password UserType1 sam@yahoo.com sam s 12 nesk@yahoo.com nesk s 23 kavi@yahoo.com kavi s 24 sim@yahoo.com sim s 1PaymentId UserId ExpertId TxnId PaymentMethod Email Price1 1 2 11 paypal a@a.com 72 4 3 12 paypal b@a.com 5 3 2 3 34 paypal c@a.com 8outputUsername PaymentMethod DebitAmount creditAmountsam paypal 0 7 sim paypal 0 5 kavi paypal 7 8 (Debit Amount means incoming, credit Amount means outgoing)This is my test queryselect (Select NickName from LP_UserManagement where UserId=P.UserId) as Username,P.CreationDateTime,PaymentMethod,TxnId,(select Sum(Price) from LP_Payment PP inner join LP_UserManagement UON PP.UserId=U.UserId where PP.UserId=P.UserId) as DebitAmount,P.* from LP_Payment P inner join LP_UserManagement U ON P.UserId=U.UserId where P.Deleted=0 order by P.creationdatetime descThanks and regardsE.sambath |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-04-29 : 07:05:52
|
| select t.Username, u.PaymentMethod, (select sum(price) from LP_Payment where t.userid = userid and userid = u.userid) as debitamount, u.price as creditAmountfrom LP_UserManagement tinner join LP_Payment as u on u.userid = t.userid |
 |
|
|
esambath
Yak Posting Veteran
89 Posts |
Posted - 2009-04-29 : 07:25:51
|
| dear bklrThank you for MessageRegardssambath kumar |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-04-29 : 07:48:10
|
| welcomedid u get the required output....... |
 |
|
|
|
|
|
|
|