talahi
asked on
Using a sql query, how to select an individual row and column data?
Background: Using an external table I loaded vertical (by column) data from an excel file. Now I want to arrange this data in rows. So basically I'm trying to convert data formatted in columns to rows. From a temp table I called each column col1, col2, col3 hoping I could
select rownum, 'col'||rownum from temp_table
from temp_table
GROUP BY rownum, 'COL'||rec_rownum HAVING rownum = 1;
but that doesn't work.
table description:
CREATE TABLE temp_table
(
COL1 VARCHAR2(20 BYTE),
COL2 VARCHAR2(20 BYTE),
COL3 VARCHAR2(20 BYTE))
ASKER
I'm not sure I see it.
I'm trying to go from data read into a table like this (temp_table_cols)
COL1 COL2 COL3
COL1 COL2 COL3
COL1 COL2 COL3
COL1 COL2 COL3
COL1 COL2 COL3
to regular rows of data like this (temp_table_rows),
COL1 col1 col1 col1 col1
COL2 col2 col2 col2 col2
COL3 col3 col3 col3 col3
I'm trying to go from data read into a table like this (temp_table_cols)
COL1 COL2 COL3
COL1 COL2 COL3
COL1 COL2 COL3
COL1 COL2 COL3
COL1 COL2 COL3
to regular rows of data like this (temp_table_rows),
COL1 col1 col1 col1 col1
COL2 col2 col2 col2 col2
COL3 col3 col3 col3 col3
your results can't be dynamic, the number of columns must be known at the time the sql statement is parsed.
how many rows do you want to convert to columns?
how many rows do you want to convert to columns?
ASKER
Just as above, 3 columns of data converted into 3 rows of data.
I hoped I could grab
COL1(1,1) and put it in ROW(1,1) and
COL1(1,2) into ROW(1,2) etc.
I hoped I could grab
COL1(1,1) and put it in ROW(1,1) and
COL1(1,2) into ROW(1,2) etc.
5 rows becomes 5 columns.
are you saying your temp_table will never have more than 5 rows of data in it?
are you saying your temp_table will never have more than 5 rows of data in it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wow, as usual I'm impressed, thanks again.
ee.txt