如何将SUM(tonnage_adjusted)
中DeliverTons
列的SELECT DISTINCT CROP_CLASS As Opened,SUM(ACREAGE) AS SumofAcreage
From CaneParcel
WHERE EXISTS (SELECT * FROM DeliveryTons WHERE CaneParcel.FIELD_ID = DeliveryTons.parcel_id AND parcel_status = 1)
Group By CROP_CLASS
Order By SumofAcreage DESC
包含到此SQL查询中以生成我需要的3列值。
{{1}}
答案 0 :(得分:2)
希望这能解决您的问题
SELECT
CROP_CLASS As Opened,
SUM(ACREAGE) AS SumofAcreage,
SUM(tonnage_adjusted) AS TonnageAdjusted
FROM
CaneParcel
INNER JOIN DeliveryTons ON CaneParcel.FIELD_ID = DeliveryTons.parcel_id AND parcel_status = 1
Group By CROP_CLASS
Order By SumofAcreage