我有这个要执行的查询。
SELECT warehouse.expiry_date, pharmacy.expiry_date,
drugs.active_substance,
drugs.strength,
drugs.strength_type,
drugs.dosage_form,
drugs.minimum_quantity,
SUM(QTY-QTYQ) as QTYU
FROM
(SELECT warehouse.expiry_date,
drugs.active_substance,
drugs.strength,
drugs.strength_type,
drugs.dosage_form,
drugs.minimum_quantity,
SUM(warehouse.in_quant)- SUM(warehouse.out_quant) as QTY
FROM drugs INNER JOIN warehouse ON drugs.ID = warehouse.drug_id
GROUP BY warehouse.expiry_date,
drugs.active_substance,
drugs.strength,
drugs.strength_type,
drugs.dosage_form,
drugs.minimum_quantity
UNION ALL
SELECT pharmacy.expiry_date,
drugs.active_substance,
drugs.strength,
drugs.strength_type,
drugs.dosage_form,
drugs.minimum_quantity,
SUM(pharmacy.out_quant)- SUM(pharmacy.out_quant) as QTYQ
FROM drugs INNER JOIN pharmacy ON drugs.ID = pharmacy.drug_id
GROUP BY pharmacy.expiry_date,
drugs.active_substance,
drugs.strength,
drugs.strength_type,
drugs.dosage_form,
drugs.minimum_quantity)
GROUP BY
warehouse.expiry_date,
drugs.active_substance,
drugs.strength,
drugs.strength_type,
drugs.dosage_form,
drugs.minimum_quantity,
pharmacy.expiry_date;
当我尝试执行它时,程序想要输入 pharmacy.expiry_date 和 QTYQ 的参数值。但是这些值在我的嵌套选择中。
请问有什么帮助吗?