How can convert a list to matrix in oracle?

by arnoldo.moen , in category: MySQL , a year ago

How can convert a list to matrix in oracle?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by edmond_brakus , a year ago

@arnoldo.moen 

You can convert a list to a matrix in Oracle by using the PIVOT clause in a SQL query. Here is an example of how you can achieve this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
SELECT *
FROM (
    SELECT column_value AS value,
           rownum AS id
    FROM TABLE(SYS.ODCIVARCHAR2LIST('A', 'B', 'C')) -- Replace the values in the list with your own list
)
PIVOT (
    MAX(value)
    FOR id IN(1, 2, 3) -- Specify the number of columns in your matrix
)
ORDER BY 1;


In this query, the SYS.ODCIVARCHAR2LIST function is used to create a list of values that you want to convert to a matrix. You can replace the values in the list with your own values. The PIVOT clause then reshapes the data from rows to columns based on the specified row numbers to create a matrix.


Make sure to adjust the number of columns and rows in the PIVOT clause according to your specific data.

Related Threads:

How can convert date format in oracle?
How can deploy wso2 in oracle?
How to convert timestamp to yyyy-mm-dd hh24:mi:ss format in oracle?
How to convert time interval in oracle to number of days in oracle?
How to list all users with select any table permission in oracle?
How to convert varchar2 to time in oracle?