Created
January 18, 2021 19:20
-
-
Save cdussud/d945b2ef66d2bbee2e524436cd679af6 to your computer and use it in GitHub Desktop.
Sequence of numbers in Redshift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- generate 10M numbers on Redshift | |
with digit as ( | |
select 0 as d union all | |
select 1 union all select 2 union all select 3 union all | |
select 4 union all select 5 union all select 6 union all | |
select 7 union all select 8 union all select 9 | |
), | |
seq as ( | |
select a.d + (10 * b.d) + (100 * c.d) + (1000 * d.d) + (10000 * e.d) + (100000 * f.d) + (1000000 * g.d) as num | |
from digit a | |
cross join | |
digit b | |
cross join | |
digit c | |
cross join | |
digit d | |
cross join | |
digit e | |
cross join | |
digit f | |
cross join | |
digit g | |
order by 1 | |
) | |
select seq.num | |
from seq; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment