我有如下的mysql查询:
SELECT
company_name,
SUM(purchase_qty * num_of_certificate) AS total_purchase_qty,
total_sold_qty,
(total_purchase_qty - total_sold_qty) AS rem_qty
FROM tbl_company
JOIN tbl_share_purchase
ON purchase_company_id = tbl_company.id
JOIN (SELECT
sold_company_id,
SUM(sold_qty) AS total_sold_qty
FROM tbl_share_sales
GROUP BY sold_company_id) s
ON s.sold_company_id = tbl_company.id
GROUP BY purchase_company_id
是否可以使用(total_purchase_qty - total_sold_qty) AS rem_qty来获取剩余数量?