我還沒有發現任何SQL連接問題相當大,這是問題:我有兩個SQL語句,一個將資金分配到單獨的組中,一個獲得花在那些團體,我如何將他們加入到一起,以便將「預算」和「費用」一起顯示出來? 很多,而不是有部門,資金類別,預算和部門,資金類別,費用表,我想要一個部門,資金類別,預算,費用表。SQL加入兩個語句
SELECT st.name as "Department", sft.longname as "Funding Category", sum(sf.amount) as "Budget"
FROM
money_type as st,
money_funding_type as sft,
money_funding as sf
WHERE
st.ID = sf.type_ID AND
sft.ID = sf.funding_ID
GROUP BY
sf.type_id, sf.funding_id
SELECT st.name as "Department", sft.longname as "Funding Category", sum(si.amount) as "Expenses"
FROM
money_type as st,
money_funding_type as sft,
money_invoice as si
WHERE
st.ID = si.type_ID AND
sft.ID = si.funding_ID
GROUP BY
si.type_id, si.funding_id
非常感謝! – user3324909