Jump to content

Pl/sql Doubt?


Recommended Posts

Posted
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
Posted

sum chesey both for deposit and withdrawals bro 

Posted

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>>;

×
×
  • Create New...