Quote Originally Posted by Jason_Kulsdom View Post
Is there an SQL term that gives the genuine subcatchment (polygon) area? I am trying to write an audit SQL that identifies all subcatchments where the total runoff area is greater than the total subcatchment area, but I want to use the genuine area of the subcatchment - not the value which has been entered in the "total area" field (which may not equal the actual area)? So something along the lines of:

Subcatchment.area < area_absolute_1 + area_absolute_2 + ... + area_absolute_12
If you set to subcatchment total area to #D flag, then it changes to the polygon area.

SET $area_store=total_area, $area_store_flag=total_area_flag;
SET total_area_flag="#D";
SET $true_area=total_area;
SET total_area=$area_store, total_area_flag=$area_store_flag;

SELECT WHERE $true_area < area_absolute_1 + area_absolute_2 + ...etc

The first line stores the current total area and total area flags into variables
Then we change the total area flag to default, which changes the total area to the polygon area. This is then stored in a variable ($true_area).
We then retrieve the total area and total area flag to set them back to their original values. You now have the '$true_area' which you can use in the rest of the query.
Alternatively, you could store the polygon area in a user number field, rather than a variable if you want to be able to actually compare them.

As to your second query; I don't believe there are any other group shortcuts. The way you've done it is how I would also do it.