我有收入的一個表作爲Mysql的加入和總和翻一番結果
title_id revenue cost
1 10 5
2 10 5
3 10 5
4 10 5
1 20 6
2 20 6
3 20 6
4 20 6
當我執行此查詢
SELECT SUM(revenue),SUM(cost)
FROM revenue
GROUP BY revenue.title_id
它產生的結果
title_id revenue cost
1 30 11
2 30 11
3 30 11
4 30 11
這是確定,現在我想結合總結果與另一個表具有這樣的結構
title_id interest
1 10
2 10
3 10
4 10
1 20
2 20
3 20
4 20
當我執行加入像這樣
SELECT SUM(revenue),SUM(cost),SUM(interest)
FROM revenue
LEFT JOIN fund ON revenue.title_id = fund.title_id
GROUP BY revenue.title_id,fund.title_id
聚合函數,雙擊它,結果
title_id revenue cost interest
1 60 22 60
2 60 22 60
3 60 22 60
4 60 22 60
我不明白爲什麼會加倍,請幫助
這是否有任何大的性能成本? – 2016-03-04 17:08:36