---
title: BQL cheatsheet
summary: Every clause, operator, function, unit and feature path of BQL on one page, each with a one-line example.
order: 500
see-also: [reference/bql/index, reference/bql/grammar]
---

# BQL cheatsheet

One line per construct; the page of each section has the details. Keywords are upper case, feature paths camelCase, IFC classes upper case, strings double-quoted.

## Clauses {#clauses}

| Clause | Example | Page |
|---|---|---|
| Bare selection | `type = IFCWALL AND property.Pset_WallCommon.IsExternal = true` | [[bql:where]] |
| `GET` | `GET qid, attribute.Name WHERE type = IFCDOOR` | [[bql:get]] |
| `AS` | `GET attribute.Name AS Name, aabb.height AS "Height (mm)"` | [[bql:get#alias]] |
| `UNIT` | `GET quantity.Qto_WallBaseQuantities.NetSideArea UNIT m2 AS Area` | [[bql:unit]] |
| `WHERE` | `GET qid WHERE type = IFCSPACE AND attribute.LongName CONTAINS "office"` | [[bql:where]] |
| `GROUP BY` | `GET type, COUNT(qid) GROUP BY type` | [[bql:group-by]] |
| `ORDER BY` | `GET qid, aabb.height WHERE type = IFCDOOR ORDER BY aabb.height DESC, attribute.Name ASC` | [[bql:order-by]] |
| `ORDER BY ORIGINAL` | `GET qid WHERE type = IFCWALL ORDER BY ORIGINAL` | [[bql:order-by#original]] |
| `ORDER BY GEOMETRY` | `GET qid WHERE type = IFCDOOR ORDER BY GEOMETRY(attribute.Name = "Entrance")` | [[bql:order-by#geometry]] |
| `LIMIT`, `OFFSET` | `GET qid WHERE type = IFCWALL LIMIT 50 OFFSET 100` | [[bql:order-by#limit]] |
| `USING` | `GET quantity.* WHERE type = IFCWALL USING LENGTH_UNIT = mm AREA_UNIT = m2 VOLUME_UNIT = m3` | [[bql:using]] |
| Comments | `GET qid // a comment` and `/* a block */` | [[page:reference/bql#conventions]] |

## Logic {#logic}

| Operator | Example |
|---|---|
| `AND`, `OR`, `NOT`, `( )` | `(type = IFCWALL OR type = IFCSLAB) AND NOT property.Pset_WallCommon.IsExternal = true` |
| `ALL` | `GET COUNT(qid) WHERE ALL` |
| Has-value | `property.*.FireRating` |
| Null | `property.Pset_DoorCommon.FireRating = null` |

## Comparators {#comparators}

| Comparator | Example | Page |
|---|---|---|
| `=` `!=` `<` `<=` `>` `>=` | `aabb.height > 2.4 m` | [[bql:where#comparisons]] |
| Feature to feature, arithmetic | `quantity.*.NetVolume > calculated.quantity.volume * 1.1` | [[bql:where#comparisons]] |
| `WITHIN` | `quantity.*.NetVolume = calculated.quantity.volume WITHIN 2 %` | [[bql:where#within]] |
| `BETWEEN` | `aabb.height BETWEEN 2.0 m AND 2.4 m`, `BETWEEN (2.0 m, 2.4 m)` | [[bql:where#comparisons]] |
| `IN`, `NOT IN` | `attribute.Name IN ("Wall-1", "Wall-2")`, `type NOT IN (IFCSPACE, IFCOPENINGELEMENT)` | [[bql:where#comparisons]] |
| `CONTAINS`, `STARTS_WITH`, `ENDS_WITH` | `attribute.Name STARTS_WITH "Basic"` | [[bql:where#strings]] |
| `MATCHES_REGEX` | `property.*.Nlsfb MATCHES_REGEX "^[0-9][0-9][.][0-9][0-9]$"` | [[bql:where#strings]] |
| `MATCHES … FUZZY` | `attribute.Name MATCHES "brandwerend" FUZZY 1` | [[bql:where#strings]] |
| `LENGTH` | `attribute.Name LENGTH > 20` | [[bql:where#strings]] |
| `CS` prefix | `attribute.Name CS = "Level 1"`, `CS CONTAINS`, `CS NOT IN (...)` | [[bql:where#strings]] |
| `type`, `NI` | `type = IFCWALL`, `type NI = IFCWALL`, `type IN (IFCWALL, IFCDOOR)` | [[bql:types]] |
| `qid` | `qid IN ("797e993c-a87f-4aa7-9587-c59d30ec5c4e-1316")` | [[bql:where#qid]] |
| Parameters | `= $x`, `IN $values`, `BETWEEN $lo AND $hi`, `type IN $types`, `qid IN $selection` | [[bql:using#parameters]] |

## Aggregates and functions {#functions}

| Function | Example | Page |
|---|---|---|
| `COUNT` | `GET type, COUNT(qid) GROUP BY type` | [[bql:group-by#aggregates]] |
| `SUM`, `AVG`, `MIN`, `MAX` | `GET SUM(quantity.Qto_SpaceBaseQuantities.NetFloorArea) WHERE type = IFCSPACE` | [[bql:group-by#aggregates]] |
| `MEDIAN`, `MODE`, `RANGE`, `STDDEV` | `GET MEDIAN(aabb.height) WHERE type = IFCDOOR` | [[bql:group-by#aggregates]] |
| `COLLECT` | `GET type, COLLECT(qid) GROUP BY type` | [[bql:group-by#aggregates]] |
| `COLLECT(DISTINCT …)` | `GET type, COLLECT(DISTINCT attribute.ObjectType) GROUP BY type` | [[bql:group-by#aggregates]] |
| `FIRST` | `GET type, COUNT(qid), FIRST(qid) GROUP BY type` | [[bql:group-by#aggregates]] |
| `BIN` | `GET BIN(aabb.height, 500 mm), COUNT(qid) GROUP BY BIN(aabb.height, 500 mm)` | [[bql:group-by#bin]] |
| `ABS`, `+ - * /` | `GET ABS(quantity.*.NetVolume - calculated.quantity.volume) UNIT m3` | [[bql:get#arithmetic]] |
| `CASE` | `GET CASE WHEN type = IFCDOOR THEN "door" ELSE "other" END AS Kind` | [[bql:functions#case]] |
| `COALESCE`, `GREATEST`, `LEAST` | `GET GREATEST(calculated.quantity.width, attribute.OverallWidth) UNIT mm AS Width` | [[bql:functions#missing]] |
| `ROUND`, `FLOOR`, `CEIL`, `MOD`, `POWER`, `SQRT` | `GET ROUND(quantity.*.Length, 500 mm) UNIT m AS Band` | [[bql:functions#numbers]] |
| `CONCAT`, `UPPER`, `LOWER`, `TRIM`, `LEFT`, `RIGHT`, `SUBSTRING`, `SPLIT_PART`, `REPLACE`, `REGEX_EXTRACT`, `CHAR_LENGTH` | `WHERE SPLIT_PART(classification.identification, ".", 1) IN ("21", "22")` | [[bql:functions#text]] |
| `TO_NUMBER`, `TO_STRING` | `WHERE TO_NUMBER(property.*.Dikte, mm) > 100 mm` | [[bql:functions#conversions]] |
| `COUNT(children)` | `GET attribute.Name, COUNT(children) WHERE type = IFCBUILDINGSTOREY` | [[bql:get#special]] |
| `eval` | `GET qid, eval(property.Pset_WallCommon.IsExternal = true) AS External` | [[bql:get#special]] |
| Relation aggregate | `spaceBoundary(SUM(quantity.*.Area) WHERE type = IFCWINDOW)` | [[bql:where#relation-aggregates]] |

## Units {#units}

| Dimension | Units |
|---|---|
| Length | `mm` `cm` `dm` `m` `km` `in` `ft` `yd` `mi` |
| Area | `mm2` `cm2` `dm2` `m2` `km2` `in2` `ft2` `yd2` `ac` `mi2` |
| Volume | `mm3` `cm3` `dm3` `m3` `in3` `ft3` `yd3` `l` |
| Mass | `mg` `cg` `g` `kg` |
| Temperature | `dc` |

`UNIT`, unit literals and `USING` take all of them ([[bql:using#units]]).

## Feature paths {#features}

| Path | Example | Page |
|---|---|---|
| `qid`, `oid`, `type`, `niceType` | `GET qid, type, niceType` | [[bql:types]] |
| `suggestedType`, `suggestion.<facet>` | `GET suggestedType WHERE suggestion.status = "CONTRADICTION"` | [[bql:types#suggestedtype]] |
| `attribute.<Name>`, `attribute.*`, `.value` | `GET attribute.Name, attribute.GlobalId, attribute.*` | [[bql:attributes]] |
| `property.<Pset>.<Name>`, `property.*.<Name>`, `property.*` | `GET property.Pset_WallCommon.IsExternal, property.*.FireRating` | [[bql:properties]] |
| Quoted names | `property."AR_Ruum"."115_Kategooria"` | [[bql:properties]] |
| Fields | `property.Pset_WallCommon.FireRating.value`, `.unit`, `.propertySetName` | [[bql:properties#fields]] |
| `quantity.<Qset>.<Name>`, `quantity.*` | `GET quantity.Qto_WallBaseQuantities.NetSideArea, quantity.*.Width` | [[bql:quantities]] |
| `classification.<field>`, `.system.<field>` | `GET classification.identity, classification.system.name` | [[bql:classifications]] |
| `calculated.quantity.<name>` | `GET calculated.quantity.floorArea, calculated.quantity.volume` | [[bql:calculated-values#quantity]] |
| `calculated.property.<name>` | `WHERE buildingStorey.calculated.property.level = 1` | [[bql:calculated-values#property]] |
| `calculated.geometry.<flag>`, `.counts.<n>` | `WHERE calculated.geometry.counts.triangles > 100000` | [[bql:calculated-values#geometry]] |
| `calculated.consistency.<check>` | `WHERE calculated.consistency.watertight = false` | [[bql:calculated-values#consistency]] |
| `aabb.<side>`, `calculated.obb.<field>` | `GET aabb.height, aabb.minz, calculated.obb.halfExtentX` | [[bql:calculated-values#aabb]] |
| `layer.name`, `layer.*` | `WHERE layer.name STARTS_WITH "A-"` | [[bql:layers]] |
| `material.<field>`, `material(...)` | `GET material.name, material(name, layerThickness)` | [[bql:materials]] |
| `model.<field>`, `model.header.<field>` | `GET model.name, model.ifcVersion, model.header.authors` | [[bql:model]] |
| `model.ifcVersion`, `model.discipline`, `model.count` | `WHERE model.ifcVersion = IFC4 AND model.count(type = IFCSPACE) > 50` | [[bql:model#conditions]] |
| `linkedData`, `linkedData.count`, `linkedData.<field>` | `GET linkedData.count WHERE linkedData.category = "Certificate"` | [[bql:linked-data]] |
| `<family>.meta` | `GET property.meta, COUNT(qid) GROUP BY property.meta` | [[bql:meta]] |

## Relations {#relations}

| Relation | Example | Page |
|---|---|---|
| `buildingStorey`, `space`, `building`, `site`, `project`, `containedIn` | `GET buildingStorey.attribute.Name WHERE type = IFCDOOR` | [[bql:building-storeys]] |
| `typeObject`, `own` | `WHERE typeObject.attribute.Name CONTAINS "Double"` | [[bql:type-objects]] |
| `parent`, `decomposes`, `children`, `allChildren` | `GET children(qid, type WHERE type = IFCDOOR LIMIT 5)` | [[bql:sub-features]] |
| `containmentChildren`, `decompositionChildren`, `decomposition` | `GET decomposition WHERE type = IFCCURTAINWALL` | [[bql:sub-features]] |
| `system`, `zone`, `port`, `portConnectedTo`, `portContainedIn` | `GET port.portConnectedTo.portContainedIn.attribute.Name` | [[bql:sub-features#systems]] |
| `spaceBoundary`, `relatedBuildingElement` | `WHERE spaceBoundary.any(relatedBuildingElement.type = IFCWINDOW)` | [[bql:sub-features#systems]] |
| `hasOpenings`, `hasFillings`, `fillings`, `fills`, `fillsVoid`, `voidsElement` | `GET fillsVoid.voidsElement.attribute.Name WHERE type = IFCDOOR` | [[bql:openings-and-fillings]] |
| `.any`, `.all`, `.count` | `WHERE children.count(type = IFCDOOR) > 2` | [[bql:sub-features#quantifiers]] |

## Spatial and advanced {#spatial}

| Construct | Example | Page |
|---|---|---|
| `CLASHES_WITH` | `WHERE type = IFCDUCTSEGMENT AND CLASHES_WITH(type = IFCBEAM)` | [[bql:spatial-and-advanced#clashes]] |
| `geometry:contains_fully`, `contains_partially`, `contained_in`, `touches` | `WHERE geometry:contained_in(type = IFCSPACE, fully)` | [[bql:spatial-and-advanced#geometry]] |
| `geometry:clearance` | `WHERE geometry:clearance(type = IFCBEAM) < 50 mm` | [[bql:spatial-and-advanced#clearance]] |
| `BOX`, `CYLINDER`, `CONE`, `SPHERE` | `CLASHES_WITH(BOX(this, 0, 0, 0, 1 m, 1 m, 1 m), type = IFCWALL)` | [[bql:spatial-and-advanced#virtual]] |
| `MAXIMUM_INSCRIBED_CIRCLE`, `_CYLINDER`, `_SQUARE` | `GET MAXIMUM_INSCRIBED_CIRCLE(geometry2d).diameter` | [[bql:spatial-and-advanced#inscribed]] |
| `geometry:usableArea`, `usableAreaFactor`, `headroom` | `GET geometry:usableArea(2.1 m)` | [[bql:spatial-and-advanced#usable-area]] |
| `sem:isBoundedBy`, `sem:providesBoundariesFor` | `WHERE type = IFCSPACE AND sem:isBoundedBy(type = IFCWINDOW)` | [[bql:spatial-and-advanced#space-boundaries]] |
| `PART_OF(SHORTEST_PATH(...))`, `PART_OF(GRAPH(...))`, `DIRECT_CONNECTIONS_TO` | `WHERE PART_OF(GRAPH(type = IFCPUMP, 3))` | [[bql:spatial-and-advanced#paths]] |
| `nav:route`, `nav:reachable`, `nav:routeLength`, `nav:hasFallHazard`, `nav:guardsFall` | `WHERE nav:routeLength(type = IFCSTAIR) > 30 m` | [[bql:spatial-and-advanced#nav]] |
| `geoReference WITHIN_EPSG`, `WITHIN_COUNTRY`, `gis:convertGeoReference` | `WHERE geoReference WITHIN_EPSG("28992")` | [[bql:spatial-and-advanced#georeference]] |
| `TEXT_MATCHES` | `WHERE TEXT_MATCHES("fire door", FUZZY 1)` | [[bql:spatial-and-advanced#text]] |
| `viewPoint` | `GET qid, viewPoint WHERE type = IFCDOOR` | [[bql:spatial-and-advanced#viewpoint]] |

## Ten queries {#ten}

```bql {#ten-1}
GET type, COUNT(qid) GROUP BY type
```

```bql {#ten-2}
GET qid, attribute.Name WHERE type = IFCWALL AND property.Pset_WallCommon.IsExternal = true
```

```bql {#ten-3}
GET property.meta, COUNT(qid) WHERE type = IFCSPACE GROUP BY property.meta
```

```bql {#ten-4}
GET buildingStorey.attribute.Name, COUNT(qid) WHERE type = IFCDOOR GROUP BY buildingStorey.attribute.Name
```

```bql {#ten-5}
GET qid, quantity.Qto_DoorBaseQuantities.Width UNIT mm WHERE type = IFCDOOR AND quantity.Qto_DoorBaseQuantities.Width < 0.85 m
```

```bql {#ten-6}
GET SUM(quantity.Qto_SpaceBaseQuantities.NetFloorArea) AS FloorArea WHERE type = IFCSPACE USING AREA_UNIT = m2
```

```bql {#ten-7}
GET qid, attribute.Name WHERE type = IFCSPACE AND typeObject.attribute.Name CONTAINS "balkon"
```

```bql {#ten-8}
GET qid, ABS(quantity.Qto_WallBaseQuantities.NetVolume - calculated.quantity.volume) UNIT m3 AS Deviation WHERE type = IFCWALL AND quantity.Qto_WallBaseQuantities.NetVolume != calculated.quantity.volume WITHIN 2 %
```

```bql {#ten-9}
GET type AS Type, COUNT(qid) AS Count, FIRST(qid) AS Sample GROUP BY type
```

```bql {#ten-10}
GET qid, attribute.Name WHERE type = IFCSLAB AND calculated.quantity.volume > $minVolume
```
