Search code examples
sqlprestoamazon-athenatrino

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.


Solution

  • You want a cross join:

    select c.*, v.temp
    from current c cross join
         (values (1), (2), (3)) v(temp);