nikhilboorla Posted March 16, 2015 Report Posted March 16, 2015 tab_Transactions transaction date transaction_type Amts 1-oct-14 Deposits 60 3-oct-14 Deposits 30 5-oct-14 Deposits 60 7-oct-14 Withdrawals -30 9-oct-14 Withdrawals -10 10-oct-14 Withdrawals -30 expected o/p: deposits withdrawals 150 -70
texas Posted March 16, 2015 Report Posted March 16, 2015 sum chesey both for deposit and withdrawals bro
Walcommon Posted March 16, 2015 Report Posted March 16, 2015 Try this.. SELECT * FROM ( (SELECT SUM (transaction_type) AS Deposits FROM tab_Transactions WHERE transaction_type = 'Deposits') a , (SELECT SUM(transaction_type) AS Withdrawals FROM tab_Transactions WHERE transaction_type = 'Withdrawals') b ) Where a.<<give the primary key here>> = b.<<give the primary key here>>;
Recommended Posts