EQL allows you to combine multiple sparse fields into a single field.
In the example below, we use the AVG and COALESCE functions to combine the leasePayment and loanPayment fields into a single avgPayment field.
| ID | Make | Model | Type | leasePayment | loanPayment |
|---|---|---|---|---|---|
| 1 | Audi | A4 | lease | 380 | |
| 2 | Audi | A4 | loan | 600 | |
| 3 | BMW | 325 | lease | 420 | |
| 4 | BMW | 325 | loan | 700 |
RETURN Result AS SELECT AVG(COALESCE(loanPayment,leasePayment)) AS avgPayment FROM CombinedColumns GROUP BY Make