Select
select name = f"{first_name} {last_name}"
SELECT
CONCAT(first_name, ' ', last_name) AS name
FROM
employees
from employees
select [
age_eoy = dob - @2022-12-31,
]
SELECT
CONCAT(first_name, ' ', last_name) AS name,
dob - DATE '2022-12-31' AS age_eoy
FROM
employees
from employees
select first_name
from e=employees
select [e.first_name, e.last_name]
SELECT
first_name,
last_name
FROM
We can use !
to exclude a list of columns. This can operate in two ways:
- We use
SELECT * EXCLUDE
/SELECT * EXCEPT
for the columns supplied toselect ![]
in dialects which support it. - Otherwise, the columns must have been defined prior in the query (unless all of a table’s columns are excluded); for example in another
select
or agroup
transform. In this case, we evaluate and specify the columns that should be included in the output SQL.
PRQL
prql target:sql.bigquery
from tracks
select ![milliseconds,bytes]
SQL
SELECT
*
EXCEPT
(milliseconds, bytes)
FROM
PRQL
from tracks
select [track_id, title, composer, bytes]
select ![title, composer]
SQL
PRQL
from artists
derive nick = name
select ![artists.*]
SQL
SELECT
name AS nick
artists
Note
from e=employees
select e.first_name
filter e.first_name == "Fred" # Can't find `e.first_name`
To refer to the e.first_name
column in subsequent transforms, either refer to it using first_name
, or if it requires a different name, assign one in the select
statement:
PRQL
from e=employees
select fname = e.first_name
filter fname == "Fred"
SQL
WITH table_1 AS (
SELECT
first_name AS fname
FROM
employees AS e
)
SELECT
fname
FROM
table_1 AS table_0