Transforms

PRQL queries are a pipeline of transformations (“transforms”), where each transform takes the previous result and adjusts it in some way, before passing it onto to the next transform.

Because PRQL focuses on modularity, we have far fewer transforms than SQL, each one fulfilling a specific purpose. That’s often referred to as “orthogonality”.

These are the currently available transforms:

TransformPurposeSQL Equivalent
fromStarts from a tableFROM
deriveComputes new columnsSELECT *, ... AS ...
selectPicks & computes columnsSELECT ... AS ...
filterPicks rows based on their valuesWHERE, HAVING,QUALIFY
sortOrders rows based on the values of columnsORDER BY
joinAdds columns from another table, matching rows based on a conditionJOIN
takePicks rows based on their positionTOP, LIMIT, OFFSET
groupPartitions rows into groups and applies a pipeline to each of themGROUP BY, PARTITION BY
aggregateSummarizes many rows into one rowSELECT foo(...)
windowApplies a pipeline to overlapping segments of rowsOVER, ROWS, RANGE