1
我從同桌兩個查詢不同之查詢,並加入他們的行列
SELECT userId,SUM(amount) AS totalDeposite FROM trx GROUP BY userId
輸出:
用戶id totalDeposite
1 470
2 30
查詢
SELECT userId,SUM(amount) AS totalFine FROM trx WHERE TYPE='fine' GROUP BY userId
輸出:
用戶id totalFine
1 20
2 30
我怎樣才能像
userId totalDeposite totalFine
1 470 20
2 30 30