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

RANK() Function

Use with AI:Rippling AI ChatGPT Claude Cursor

Description​

Assigns a rank to each row within a partition of a result set

Syntax​

RANK() 
OVER (
[PARTITION BY partition_expression]
ORDER BY sort_expression [ASC|DESC]
)

Parameters​

ParameterDescriptionData TypeRequired
PARTITION BYDivides the result set into groups before applying the window functionClauseNo
ORDER BYDefines how rows are ordered within the partitionClauseYes

Rewrite​

Use QUALIFY to filter on window expression results; do not use window functions in WHERE.

Notes​

  • Include an OVER (...) clause with ORDER BY (and optional PARTITION BY) when using this as a window function.

Example​

SELECT
department, full_name, RANK() OVER (PARTITION BY department ORDER BY start_date DESC) AS rank
FROM
rippling.employee.Employee;