{question}
Is the function UNPIVOT
supported in SingleStore?
If not, is there an alternative to this function?
{question}
{answer}
The UNPIVOT
feature is currently not supported in SingleStore.
As an alternative, you can use UNION ALL
to achieve similar functionality.
Here’s an example demonstrating this approach:
create table unpivot_test(id int, col1 varchar(255), col2 varchar(255), col3 varchar(255)); insert into unpivot_test(id,col1,col2,col3) values(1,'a1','b1','c1'),(2,'a2','b2','c2');
Table data:
select * from unpivot_test;
Unpivoted data using UNION ALL:
select id, col1 value from unpivot_test union all select id, col2 value from unpivot_test union all select id, col3 value from unpivot_test;
{answer}