Let statement
This page explains how to bind variables, tabular expressions, and user-defined functions with the let statement in APL.
The let statement binds a name to a scalar expression, a tabular expression, or a user-defined function for the remainder of the query. Terminate each let statement with a semicolon (;).
Syntax
APL
Scalar variables
Bind constants or computed expressions to reuse across filters and projections.
Query
APL
Tabular expressions
Bind a query or inline datatable to reuse in join, lookup, or union operations.
Query
APL
User-defined functions
Define reusable scalar functions with typed parameters and optional default values. Functions can reference scalar variables declared earlier in the query.
Query
APL
Output
| n | shifted | custom |
|---|---|---|
| 1 | 8 | 11 |
| 2 | 9 | 12 |
| 3 | 10 | 13 |
Related statements
- Set statement: Sets query options for the duration of a query.
- Declare query_parameters: Declares typed parameters with defaults for parameterized queries.