Skip to content
Advertisement

Presto SQL – Looking to explode Table of IDs to include predefined row numbers

Apologies if this title was a bit confusing. It’s tough to articulate this problem in a sentence.

Here is my current table

ID
A
B
C

I’d like to explode this table to look like this:

ID temp
A. 1
A. 2
A. 3  
B. 1
B. 2
B. 3
C. 1
C. 2
C  3

Any help would be much appreciated.

Advertisement

Answer

You want a cross join:

select c.*, v.temp
from current c cross join
     (values (1), (2), (3)) v(temp);
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement