TOP

circle-info

Important Notice: Migration of Documentation Website

Please be advised that our documentation website is currently undergoing a migration to a new platform. To ensure you have access to the most up-to-date information, we kindly request that you visit our new documentation website located at:

Official Snowflake Snowconvert Documentationarrow-up-right

For any immediate assistance or if you encounter any issues, please contact our support team at [email protected]envelope.

Thank you for your understanding.

chevron-rightApplies tohashtag

Description

circle-info

Some parts in the output code are omitted for clarity reasons.

Limits the rows returned in a query result set to a specified number of rows or percentage of rows. When you use TOP with the ORDER BY clause, the result set is limited to the first N number of ordered rows. Otherwise, TOP returns the first N number of rows in an undefined order. Use this clause to specify the number of rows returned from a SELECT statement. Or, use TOP to specify the rows affected by an INSERT, UPDATE, MERGE, or DELETE statement. (Transact-SQL TOP documentationarrow-up-right)

Syntax in Transact-SQL

TOP (expression) [PERCENT] [ WITH TIES ]
circle-info

To get more information about the TOP arguments please check the Transact-SQL TOP documentationarrow-up-right.

Syntax in Snowflake

circle-info

To get more information about TOP arguments please check the Snowflake TOP documentationarrow-up-right.

Sample Source Patterns

To execute correctly the following samples it is required run the next CREATE TABLE statement:

Common Case

Transact-SQL

Snowflake

TOP using PERCENT

Transact-SQL

Snowflake

circle-exclamation

TOP WITH TIES

Transact-SQL

Snowflake

circle-exclamation

Known Issues

1. PERCENT argument is not supported by Snowflake

Since the PERCENT argument is not supported by Snowflake it is being removed from the TOP clause and a warning is being added. Functional equivalence mismatches in the results could happen.

2. WITH TIES argument is not supported by Snowflake

Since the WITH TIES argument is not supported by Snowflake it is being removed from the TOP clause and a warning is being added. Functional equivalence mismatches in the results could happen.

  1. SSC-EWI-0040: Statement Not Supported.

Last updated