1

I have a set of n ids, say table 1, like so:

id
id_1
id_2
...
id_n

I would like to combine this with a set of numbers 1...m (m is medium large here, i.e. between a hundred and a thousand) to get a table that looks like this:

id number
id_1 1
id_1 2
... ...
id_1 m
id_2 1
... ...
id_2 m
... ...
id_n m

That is the size of this, say table 2, is going to be m*n.

Is something like this possible in SQL? The dialect I am using is Snowflake.

clog14
  • 1,549
  • 1
  • 16
  • 32

1 Answers1

3

Just a cross join should work right?

Substituting "10" for m

SELECT IT.id,
       INT_SEQ.seq_val
  FROM ID_TABLE IT
 CROSS
  JOIN
       (select row_number() over(order by 0) AS seq_val
          from table(generator(rowcount => 10)) v 
       ) INT_SEQ
Error_2646
  • 2,555
  • 1
  • 10
  • 22