---
title: BQL
summary: The BIM.works Query Language, clause by clause — what a query is, the order of its clauses, the model parameter, the response shape, and an index of every feature page.
order: 10
terms: [bql, qid, pset, quantity-set]
see-also: [reference/bql/cheatsheet, tutorials/bql, how-to/query, explanation/the-query-languages]
---

# BQL

BQL selects objects from one or more IFC models and returns features of them. This page is the map of the language; every clause and feature family has its own page below, and the [[bql:cheatsheet]] compresses all of them into one card. The grammar the parser is generated from is on the [[bql:grammar]] page.

## What a query is {#what}

A query has two halves. The **selection** is a boolean expression over objects (`type = IFCWALL AND property.Pset_WallCommon.IsExternal = true`); the **projection** is the `GET` list of features to return for each selected object (`GET qid, attribute.Name`). Either half can be omitted:

- A query without `GET` is a bare boolean expression and returns the matching objects with their default fields. This is the form the viewers and the visualisation language use.
- A query with `GET` and no `WHERE` projects every object of the models.

There is no `FROM`: the models are a parameter of the API call, not part of the query ([models](#models)).

```bql {#bare-selection}
type = IFCWALL AND property.Pset_WallCommon.IsExternal = true
```

```bql {#projection}
GET qid, attribute.Name, property.Pset_WallCommon.IsExternal WHERE type = IFCWALL
```

## Clause order {#clause-order}

Clauses are optional but their order is fixed:

```text {#clause-skeleton}
GET <feature> [UNIT <unit>] [AS <alias>], ...
WHERE <boolean expression>
GROUP BY <feature>, ...
ORDER BY <feature> [ASC|DESC], ... | ORDER BY ORIGINAL | ORDER BY GEOMETRY(<expression>)
LIMIT <n>
OFFSET <n>
USING LENGTH_UNIT = <unit> AREA_UNIT = <unit> VOLUME_UNIT = <unit> MASS_UNIT = <unit> TEMPERATURE_UNIT = <unit>
```

| Clause | Page | Notes |
|---|---|---|
| `GET` | [[bql:get]] | Features, arithmetic, aggregates, `AS` aliases, nested relation queries. |
| `UNIT` | [[bql:unit]] | Per `GET` item; converts one numeric feature. Not on aggregates. |
| `WHERE` | [[bql:where]] | Boolean expressions, comparators, string tests, tolerances. Requires `GET` before it; without `GET` write the expression on its own. |
| `GROUP BY` | [[bql:group-by]] | One or more keys; pairs with the aggregate functions. |
| `ORDER BY`, `LIMIT`, `OFFSET` | [[bql:order-by]] | Sorting, original order, spatial sequencing, paging. |
| `USING` | [[bql:using]] | Output units for the whole result; parameters (`$name`) are on the same page. |

## A complete example {#example}

The external walls of the demo model, largest side area first, with their storey and their net side area in square metres:

```bql {#complete-example}
// External walls, largest first
GET
    qid,
    attribute.Name AS Name,
    buildingStorey.attribute.Name AS Storey,
    quantity.Qto_WallBaseQuantities.NetSideArea UNIT m2 AS SideArea
WHERE
    type = IFCWALL
    AND property.Pset_WallCommon.IsExternal = true
    AND quantity.Qto_WallBaseQuantities.NetSideArea > 5 m2
ORDER BY quantity.Qto_WallBaseQuantities.NetSideArea DESC
LIMIT 20
```

Line by line: `qid` is the object's [[term:qid|Qid]]; `attribute.Name` is the IFC attribute ([[bql:attributes]]); `buildingStorey.attribute.Name` follows the containment relation to the storey and reads its name ([[bql:building-storeys]]); the quantity comes from the wall's base quantity set ([[bql:quantities]]) and is converted to m² ([[bql:unit]]); the `WHERE` filters on type ([[bql:types]]) and on a property of the common property set ([[bql:properties]]); `ORDER BY … DESC LIMIT 20` keeps the twenty largest ([[bql:order-by]]).

## Models are a parameter {#models}

A query never names a model. The API call that runs it carries the models: a list of version UUIDs in the SDKs (`client.bim.query([versionUuid], query)` in JavaScript, `client.bim.query(query, Set.of(versionUuid))` in Java), or a `models` array of `ModelIdentifier` objects in the [[openapi:Query]] operation. One query runs over every model in the list at once, and each returned object carries the version it came from in its Qid. An empty model list is valid and only validates the query. The [[bql:model]] page describes the `model.*` features that read the model's own name, schema and header.

## Response shape {#response}

The result is a JSON array with one record per selected object (or per group when the query has `GROUP BY`). A record is an object whose keys are the selected feature paths; nested paths (`buildingStorey.attribute.Name`) become nested objects. An `AS` alias is the key of a computed column (arithmetic, `UNIT`, an aggregate); a plain feature keeps its path ([[bql:get#alias]]). A leaf value is an object with the value and its metadata:

```json {#record-example}
{
  "qid": "797e993c-a87f-4aa7-9587-c59d30ec5c4e-1316",
  "type": "IFCWALL",
  "attribute": {
    "Name": {"name": "Name", "type": "STRING", "value": "Basic Wall:Exterior", "classType": "IfcLabel"}
  },
  "property": {
    "Pset_WallCommon": {
      "IsExternal": {"name": "IsExternal", "type": "BOOLEAN", "value": true, "classType": "IFCBOOLEAN", "propertySetName": "Pset_WallCommon"}
    }
  }
}
```

`type` is the `BasicType` of the value (`STRING`, `BOOLEAN`, `DOUBLE`, `INT`, `ENUM`, `REFERENCE`, …); numeric values carry a `unit`; properties and attributes that come from the object's type object carry `origin: "type"` ([[bql:type-objects]]). Records omit features the object has no value for. Aggregates appear under their alias or else their keyword (`COUNT`, `MAX`, …); `SUM` and `COLLECT` under their full text, such as `SUM(quantity.*.NetVolume)` ([[bql:output#values]]). The [[bql:output]] page has the full description, including the compact format and the IFC export.

## Conventions {#conventions}

- **Keywords** are upper case (`GET`, `WHERE`, `AND`, `IN`, `CONTAINS`); feature names and relation names are camelCase (`buildingStorey`, `typeObject`); IFC class names are upper case (`IFCWALL`).
- **Strings** are double-quoted: `"Level 1"`. Single quotes are accepted by the lexer, but every example and every writer of BQL uses double quotes.
- **Names with special characters** (spaces, dashes, a leading digit) are quoted: `property."AR_Ruum"."115_Kategooria"`. Attribute names are never quoted; they follow the IFC schema and are case-sensitive.
- **Numbers** are plain decimals with an optional unit: `2.5 m`, `500 mm`, `20 m2`. There is no exponent notation. The minus sign is part of the number, so write subtractions with spaces: `a - 3`, not `a -3`.
- **Booleans and null** are lower case: `true`, `false`, `null`.
- **Comments**: `// to the end of the line` and `/* … */`.
- **Case**: string comparisons are case-insensitive unless prefixed with `CS`; IFC class names must be upper case (`ifcwall` is rejected with a did-you-mean).

## Pages {#pages}

Statement pages: [[bql:get]] · [[bql:where]] · [[bql:group-by]] · [[bql:order-by]] · [[bql:unit]] · [[bql:using]]

Feature pages: [[bql:types]] · [[bql:attributes]] · [[bql:properties]] · [[bql:quantities]] · [[bql:classifications]] · [[bql:calculated-values]] · [[bql:building-storeys]] · [[bql:layers]] · [[bql:materials]] · [[bql:type-objects]] · [[bql:sub-features]] · [[bql:openings-and-fillings]] · [[bql:model]] · [[bql:linked-data]] · [[bql:meta]]

Further: [[bql:shapes]] · [[bql:spatial-and-advanced]] · [[bql:output]] · [[bql:ast]] · [[bql:cheatsheet]] · [[bql:grammar]]

Errors a query can raise are listed under [[page:reference/errors#BimWorksQueryError|BimWorksQueryError]] on the error codes page.

## Used in {#used-in}

- [[page:tutorials/bql/your-first-query]] — the first `GET` and `WHERE`.
- [[page:how-to/query/run-a-bql-query]] — running a query from every SDK.
- [[page:how-to/query/query-multiple-models]] — one query over several versions.
