For AI agents: an index of this documentation is at https://developer.rippling.com/llms.txt. Public pages have a Markdown version at the same URL with .md added.

Skip to main content
Index

PIVOT Keyword

Use with AI:Rippling AI ChatGPT Claude Cursor

Description​

Rotates a table by turning the unique values from one column in the input expression into multiple columns and aggregating results on specified column values

Syntax​

SELECT non-pivoted_columns, [pivoted_column1], [pivoted_column2], ...
FROM (
SELECT column_list
FROM table_name
) AS source
PIVOT (
aggregate_function(value_column)
FOR pivot_column IN ([pivoted_column1], [pivoted_column2], ...)
) AS pivot_table;

Notes​

  • Limitation: only supported on known values

Example​

WITH
emp AS (
SELECT
e.id AS id,
"'engineering'" AS eng,
"'devops'" AS dev
FROM rippling.employee.Employee e
PIVOT (
MAX(YEAR(e.start_date)) FOR e.department IN ('engineering', 'devops')
)
)
SELECT
id,
eng,
dev
FROM
emp;