Query structure
Every JQL query says what result you want and which JSON file contains the data.
Every query needs select and from:
select {fields} from 'file.json'
For example:
jql "select {name, email} from 'customers.json'"
Main clauses
| Clause | What it does |
|---|---|
select | Describes the fields and shape of the result. |
from | Chooses the JSON file. |
join | Combines related records from another file. |
where | Keeps records that match a condition. |
group by | Creates groups for summaries. |
having | Keeps groups that match a condition. |
sort | Orders the final array by output fields. |
The remaining clauses are optional.
A complete query
select {region, revenue: sum(amount)}
from 'orders.json'
where status = 'paid'
group by region
having revenue >= 100
sort !revenue
JQL reads this query in a predictable order:
- Read
orders.json. - Keep paid orders.
- Group them by region.
- Calculate revenue for every region.
- Keep regions whose revenue is at least
100. - Sort the resulting regions by revenue.
Object and summary results
Braces create one object for every matching record:
select {id, name} from 'customers.json'
A named function list without braces creates one summary object:
select customers: count(id) from 'customers.json'
Keywords
Keywords and function names are case-insensitive, but JQL documentation uses lowercase as the conventional style. Field names and string values keep their original case. Unicode field names are supported.
JQL also accepts where before from:
select {id} where active = true from 'customers.json'
The usual from ... where ... order is easier to read and is used throughout this documentation.