SELECT( (SELECT SUM(`количество` `цена`) AS `сумма` FROM `покупка` WHERE ...) - (SELECT SUM(`количество` `цена`) AS `сумма` FROM `продажа` WHERE ...) ) AS `остаток`