Returns a sequence of monotonically increasing integers, with wrap-around.
Wrap-around occurs after the largest representable integer of the integer
width (1, 2, 4, or 8 byte).

Important

This function uses sequences to produce a unique set of increasing integers,
but does not necessarily produce a gap-free sequence. When operating on a
large quantity of data, gaps can appear in a sequence. If a fully ordered,
gap-free sequence is required, consider using the [ ROW_NUMBER  ](row_number)
window function.

For more details about sequences in Snowflake, see [ Using Sequences
](../../user-guide/querying-sequences) .

##  Syntax  ¶

    
    
    SEQ1( [0|1] )
    
    SEQ2( [0|1] )
    
    SEQ4( [0|1] )
    
    SEQ8( [0|1] )
    

Copy

##  Usage Notes  ¶

  * If the optional sign argument is 0, the sequence continues at 0 after wrap-around. If the optional sign argument is 1, the sequence continues at the smallest representable number based on the given integer width. 

  * The default sign argument is 0. 

##  Examples  ¶

These are basic examples of using sequences:

>
>     SELECT seq8() FROM table(generator(rowCount => 5));
>  
>     +--------+
>     | SEQ8() |
>     |--------|
>     |      0 |
>     |      1 |
>     |      2 |
>     |      3 |
>     |      4 |
>     +--------+
>  
>
> Copy
>  
>  
>     SELECT * FROM (SELECT seq2(0), seq1(1) FROM table(generator(rowCount =>
> 132))) ORDER BY seq2(0) LIMIT 7 OFFSET 125;
>  
>     +---------+---------+
>     | SEQ2(0) | SEQ1(1) |
>     |---------+---------|
>     |     125 |     125 |
>     |     126 |     126 |
>     |     127 |     127 |
>     |     128 |    -128 |
>     |     129 |    -127 |
>     |     130 |    -126 |
>     |     131 |    -125 |
>     +---------+---------+
>  
>
> Copy

This example shows how to use ROW_NUMBER to generate a sequence without gaps:

>
>     SELECT ROW_NUMBER() OVER (ORDER BY seq4())
>         FROM TABLE(generator(rowcount => 10));
>     +-------------------------------------+
>     | ROW_NUMBER() OVER (ORDER BY SEQ4()) |
>     |-------------------------------------|
>     |                                   1 |
>     |                                   2 |
>     |                                   3 |
>     |                                   4 |
>     |                                   5 |
>     |                                   6 |
>     |                                   7 |
>     |                                   8 |
>     |                                   9 |
>     |                                  10 |
>     +-------------------------------------+
>  
>
> Copy

Was this page helpful?

Yes  No

[ Visit Snowflake ](https://www.snowflake.com)

[ Join the conversation ](https://community.snowflake.com/s/)

[ Develop with Snowflake ](https://developers.snowflake.com)

[ Share your feedback ](/feedback)

[ Read the latest on our blog ](https://www.snowflake.com/blog/)

[ Get your own certification ](https://learn.snowflake.com)

[ Privacy Notice ](https://www.snowflake.com/privacy-policy/) [ Site Terms
](https://www.snowflake.com/legal/snowflake-site-terms/) ©  2024  Snowflake,
Inc.  All Rights Reserved  .

On this page

  1. Syntax 
  2. Usage Notes 
  3. Examples 

Language  :  **English**

  * [ English ](/en/sql-reference/functions/seq1)
  * [ Français ](/fr/sql-reference/functions/seq1)
  * [ Deutsch ](/de/sql-reference/functions/seq1)
  * [ 日本語 ](/ja/sql-reference/functions/seq1)
  * [ 한국어 ](/ko/sql-reference/functions/seq1)
  * [ Português ](/pt/sql-reference/functions/seq1)