如何連接下面的兩條select語句以作爲一條語句使用?我希望結果出現在一張表中。謝謝你的幫助。加入兩條包含一個WHERE子句的MySQL SELECT語句
首先聲明 -
SELECT Account_ID, SUM(Profit_Loss) AS Starting_Balance
FROM client_ledger_history
WHERE Summary = 'Cash In'
GROUP BY Account_ID WITH ROLLUP
第二條語句 -
SELECT
client_ig_client_list.Account_ID,
client_ig_client_list.`Name`,
Share_Status,
Forex_Status,
Index_Status,
Share_Weighting,
Forex_Weighting,
Index_Weighting,
SUM(
client_ledger_history.Profit_Loss
) AS Current_Balance
FROM
client_ledger_history
LEFT JOIN client_ig_client_list ON client_ig_client_list.Account_ID = client_ledger_history.Account_ID
GROUP BY
Account_ID WITH ROLLUP
如果您提供的樣本數據你的問題會比較清楚和預期的結果。 –