dataengref migrate

Home / Oracle

Oracle ROWNUM in Snowflake, Databricks and BigQuery

None of the targets has ROWNUM. Use LIMIT for "first n rows" filters and ROW_NUMBER() OVER (...) when the number itself is needed.

Oracle syntax: ROWNUM · Oracle docs

Equivalents

TargetSupportSyntaxNotesSource
SnowflakeRewriteLIMIT n / ROW_NUMBER() OVER (ORDER BY ...)QUALIFY ROW_NUMBER() OVER (...) <= n filters on the window result without a subquery.Snowflake docs
DatabricksRewriteLIMIT n / row_number() OVER (ORDER BY ...)QUALIFY is supported as well.Databricks docs
BigQueryRewriteLIMIT n / ROW_NUMBER() OVER (ORDER BY ...)QUALIFY is supported as well.BigQuery docs

Behavior differences to check

Examples

Top 10 customers by revenue

Oracle
SELECT * FROM (SELECT customer_id, revenue FROM customers ORDER BY revenue DESC) WHERE ROWNUM <= 10;
Snowflake
SELECT customer_id, revenue FROM customers ORDER BY revenue DESC LIMIT 10;
Databricks
SELECT customer_id, revenue FROM customers ORDER BY revenue DESC LIMIT 10;
BigQuery
SELECT customer_id, revenue FROM customers ORDER BY revenue DESC LIMIT 10;

Other Oracle functions

Last checked: · Paste a whole query into the SQL checker to find every function that needs a change.