Derive

Computes one or more new columns.

  1. derive {
  2. name = expression,
  3. # or
  4. column,
  5. }

Examples

PRQL

  1. from employees
  2. derive gross_salary = salary + payroll_tax

SQL

  1. SELECT
  2. *,
  3. salary + payroll_tax AS gross_salary
  4. FROM
  5. employees

PRQL

  1. from employees
  2. derive {
  3. gross_salary = salary + payroll_tax,
  4. gross_cost = gross_salary + benefits_cost
  5. }

SQL

  1. SELECT
  2. *,
  3. salary + payroll_tax AS gross_salary,
  4. salary + payroll_tax + benefits_cost AS gross_cost
  5. FROM
  6. employees