The following scenario describes how to manipulate records in a dynamically computed range value.
In the following example:
DEFINE CustomerTotals AS SELECT SUM(SalesAmount) AS Total GROUP BY CustomerKey ; DEFINE Range AS SELECT MAX(Total) AS MaxVal, MIN(Total) AS MinVal, ((MaxVal-MinVal)/10) AS Decile, MinVal + (Decile*9) AS Top10Pct FROM CustomerTotals GROUP ; RETURN Result AS SELECT SUM(SalesAmount) AS Total, Total-Range[].Top10Pct AS Diff GROUP BY CustomerKey HAVING Diff>0