DEFINE
is used to generate an intermediate result that will not be included in the query result.
All EQL statements begin with either DEFINE
or RETURN
.
You can use multiple DEFINE
clauses to make results available to other statements. Typically, DEFINE
clauses are used to look up values, compare attribute values to each other, and normalize data.
DEFINE
syntax is:
DEFINE <recordSetName> AS ...
Note that the statement name cannot be the same as the state name or as any other statement.DEFINE RegionTotals AS SELECT SUM(Amount) AS Total FROM SaleState GROUP BY Region; RETURN ProductPct AS SELECT 100*SUM(Amount) / RegionTotals[Region].Total AS PctTotal FROM RegionTotals GROUP BY Region, Product Type