| How to join a table column names with data from other table [message #561064] |
Wed, 18 July 2012 11:18  |
 |
ravidhanek
Messages: 12 Registered: August 2011
|
Junior Member |
|
|
Hi,
I am trying to join column names from a table with data from a different table. I think i should be able to pass the parameter to a 'select list' in a query. Look at my sample data below. And the data in sales table can grow till 15 rows and similarly corresponding columns in saleshist.
CREATE TABLE SALESHIST
(
PRODUCT VARCHAR2(30 BYTE),
Q1 VARCHAR2(30),
Q2 VARCHAR2(30),
Q3 VARCHAR2(30),
Q4 VARCHAR2(30)
)
Insert into SALESHIST
(PRODUCT, Q1, Q2, Q3, Q4)
Values
('Oracle EE', 100, 'AAA', 130, 128);
CREATE TABLE SALES
(
REGION VARCHAR2(10)
)
INSERT INTO SALES values('Q1');
INSERT INTO SALES values('Q2');
Desired output :
product column2 column3
'Oracle EE' 'Q1=100' 'Q2=AAA'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|