Skip to main content

Sample Queries

1. Basic select with pagination#

select id, serialNumber, subject, status from workorderwhere priority = 'Low' limit 100 offset 0

Lookup / state fields return a flat id value, not a nested object:

{  "data": [    { "id": 5001, "serialNumber": "WO-5001", "subject": "AC not cooling", "status": 21 },    { "id": 5002, "serialNumber": "WO-5002", "subject": "Leaking faucet", "status": 22 }  ]}

2. Lookup traversal#

select id, vendor, vendor.name, vendor.moduleState.displayNamefrom workorder where vendor.name like '%Cooling%' limit 25
{  "data": [    {      "id": 5001,      "vendor": 88,      "vendor.name": "Arctic Cooling Co.",      "vendor.moduleState.displayName": "Active"    }  ]}

3. Aggregate with group by and alias#

select category, status, sum(totalCost) as totalSpend, count(id) as woCountfrom workorder where priority = 'Low'group by category, status order by totalSpend desc
{  "data": [    { "category": "HVAC", "status": 21, "totalSpend": 124000, "woCount": 14 },    { "category": "Plumbing", "status": 22, "totalSpend": 43000, "woCount": 9 }  ]}

4. Full reference query#

select id, sum(totalCost), serialNumber, subject, status,       multi_enum_field_workorder as enumLabels, multi_lookup_field_workorder,       priority, priority.displayName, vendor, vendor.name, lookup_workorder_1,       vendor.moduleState, vendor.moduleState.displayNamefrom workorder where priority = 'Low'group by category, status order by createdTime desc, id asclimit 100 offset 0
tip

For a token-by-token explanation of the full reference query, see Syntax & Grammar.