Skip to content

Instantly share code, notes, and snippets.

@FrankDeGroot
Created September 25, 2013 11:06
Show Gist options
  • Save FrankDeGroot/6698127 to your computer and use it in GitHub Desktop.
Save FrankDeGroot/6698127 to your computer and use it in GitHub Desktop.
Generate max 2^32 rows with a unique number.
with a(n) as (select 0 union all select 1),
b(n) as (select 2*x.n+y.n from a x, a y),
c(n) as (select 4*x.n+y.n from b x, b y),
d(n) as (select 16*x.n+y.n from c x, c y),
e(n) as (select 256*x.n+y.n from d x, d y),
f(n) as (select 65536*x.n+y.n from e x, e y)
select top 100000000 n from f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment