This is my table data from table Mysql
t_Id t_Type t_Date t_acd_Id t_acc_Id t_Amount t_Desc t_u_Id c_Id
------ ------ ---------- -------- -------- -------- ------ ------ --------
1 0 2016-01-26 266 29 400.00 1 1
2 0 2016-01-27 266 29 160.00 1 1
3 1 2016-01-28 29 266 83.30 1 1
4 2 2016-01-27 29 272 400.00 1 1
5 0 2016-01-27 266 272 300.00 1 1
6 1 2016-01-28 272 22 20.00 1 1
I want to get the result, for example
accout_Id rec_Amount pay_Amount
------ ---------- ----------
29 483.30 560.00
where rec_Amountis the sum t_acd_Idand pay_Amountis the sumt_acc_Id
How to get this result?
My current request is
SELECT
(SELECT SUM(t_Amount) FROM tbl_transactions WHEREt_acd_Id = 29) AS rec_Amount,
(SELECT SUM(t_Amount) FROM tbl_transactions WHEREt_acc_Id= 29) AS pay_Amount
FROM tbl_transactions
which gives a few lines
source
share