1

How do I convert a column containing array values into separate columns:

Multiple rows, one column

{100,67,9}
{100,100}   
{100,100,100}
{100,9}

Multiple rows, multiple columns

100 67  9
100 100 
100 100 100
100 9   

1 Answer 1

2

A SQL query has a fixed set of columns. If you know the maximum number, then just extract the values:

select t.ar[1] as col1, t.ar[2] as col2, t.ar[3] as col3
from t;

If you don't know how many columns will be in the result set, then you would need to use dynamic SQL.

Here is a db<>fiddle.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.