Hi There, as a new developer I was hoping someone out there could answer this for me.
Is it possible to use the SUM function on a field that has been already SUMmed ?
eg, How would I manage to get the total of the Payments Column in this example.
SELECT DISTINCT
e.description,
SUM(a.hectares) Area,
b.rate,
SUM(a.HECTARES * b.RATE) Payment,
c.occ_id
FROM G_FIELD_AREA_ZONATION a,
G_PAYMENT_RATE b,
G_OCCUPIER c,
G_FIELD d,
G_ZONATION_TYPE e,
G_HOLDING f,
G_SEASON g
WHERE a.znt_id IN (SELECT znt_id FROM G_ZONATION_TYPE)
AND c.occ_id = &Occupier_Id
AND c.occ_id = f.occ_id
AND f.HLD_ID = d.HLD_ID
AND b.sea_id = g.sea_id
AND a.ZNT_ID = e.ZNT_ID
AND d.FLD_ID = a.fld_id
AND e.ZNT_ID = b.ZNT_ID
GROUP BY e.description,b.rate, c.occ_id
Many thanks to any of you who can help.
Is it possible to use the SUM function on a field that has been already SUMmed ?
eg, How would I manage to get the total of the Payments Column in this example.
SELECT DISTINCT
e.description,
SUM(a.hectares) Area,
b.rate,
SUM(a.HECTARES * b.RATE) Payment,
c.occ_id
FROM G_FIELD_AREA_ZONATION a,
G_PAYMENT_RATE b,
G_OCCUPIER c,
G_FIELD d,
G_ZONATION_TYPE e,
G_HOLDING f,
G_SEASON g
WHERE a.znt_id IN (SELECT znt_id FROM G_ZONATION_TYPE)
AND c.occ_id = &Occupier_Id
AND c.occ_id = f.occ_id
AND f.HLD_ID = d.HLD_ID
AND b.sea_id = g.sea_id
AND a.ZNT_ID = e.ZNT_ID
AND d.FLD_ID = a.fld_id
AND e.ZNT_ID = b.ZNT_ID
GROUP BY e.description,b.rate, c.occ_id
Many thanks to any of you who can help.