Skip to content
Advertisement

Update rows limit in Snowflake

I there a way to update values for top-n/limit amount of records in Snowflake?

Sample data, top rows are the ones that need to flaged:

enter image description here

The logic must combine SELECT n FROM limit 200 with SET FLAG = 1

Below syntax is not working:

Advertisement

Answer

If you need to update only a limited number of rows, you can try this with seq8():

enter image description here

enter image description here

Note: if you’re doing this over large amounts of data, seq8() might behave in unexpected ways. https://docs.snowflake.com/en/sql-reference/functions/seq1.html

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement