可以將下面的查詢合併爲單個查詢,我基本上有興趣獲得最後查詢給出的結果。結合數學查詢MySQL
#This is wrong SQL only intended as pseudocode
SELECT sum(amt) u FROM entry WHERE en_type='some_type' AND num='some_num';
SELECT sum(amt) v FROM entry WHERE en_type='some_other_type' AND num='some_num';
SELECT abal x FROM accounts WHERE num='the_same_num_as_above';
SELECT y = x + v - u;
u = v在你的例子中... –
我編輯了這個問題。現在它不會暗示u = v。 – SRM