実行したいこのクエリがあります。
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 のパラメーター値を入力したいと考えています。しかし、これらの値はネストされた選択範囲にあります。
何か助けてください。