web/book/src/reference/stdlib/transforms/select.md
Picks and computes columns.
select {
name = expression,
# or
column,
}
# or
select !{column}
from employees
select name = f"{first_name} {last_name}"
from employees
select {
name = f"{first_name} {last_name}",
age_eoy = dob - @2022-12-31,
}
from employees
select first_name
from e=employees
select {e.first_name, e.last_name}
We can use ! to exclude a list of columns. This can operate in two ways:
SELECT * EXCLUDE / SELECT * EXCEPT for the columns supplied to
select !{} in dialects which support it.select or a
group transform. In this case, we evaluate and specify the columns that
should be included in the output SQL.Some examples:
prql target:sql.bigquery
from tracks
select !{milliseconds, bytes}
from tracks
select {track_id, title, composer, bytes}
select !{title, composer}
from artists
derive nick = name
select !{artists.*}
Note that ! is also the NOT operator, so without the tuple it has a
different meaning:
prql target:sql.bigquery
from tracks
select !is_compilation