|
|
|
|
|
Re: row to column [message #648894 is a reply to message #648889] |
Sun, 06 March 2016 23:16 |
|
poppop
Messages: 3 Registered: March 2016
|
Junior Member |
|
|
hello i have query as below this execution time is to long. please introduced me to try a different solution .there is my query(oracle 10g)
SELECT *
FROM (WITH T AS (SELECT COR_ID, COR_COD, WEI1, DAYS, 'WEI1' WEI_TYPE
FROM (TABLE))
SELECT *
FROM T PIVOT(MAX(WEI1) FOR(DAYS) IN('01' DAY_01,
'02' DAY_02,
'03' DAY_03,
'04' DAY_04,
'05' DAY_05,
'06' DAY_06,
'07' DAY_07,
'08' DAY_08)))
UNION
FROM (WITH T AS (SELECT COR_ID, COR_COD, WEI1, DAYS, 'WEI2' WEI_TYPE
FROM (TABLE))
SELECT *
FROM T PIVOT(MAX(WEI2) FOR(DAYS) IN('01' DAY_01,
'02' DAY_02,
'03' DAY_03,
'04' DAY_04,
'05' DAY_05,
'06' DAY_06,
'07' DAY_07,
UNION
FROM (WITH T AS (SELECT COR_ID, COR_COD, WEI3, DAYS, 'WEI2' WEI_TYPE
FROM (TABLE))
SELECT *
FROM T PIVOT(MAX(WEI3) FOR(DAYS) IN('01' DAY_01,
'02' DAY_02,
'03' DAY_03,
'04' DAY_04,
'05' DAY_05,
'06' DAY_06,
'07' DAY_07,
'08' DAY_08)))
how change this query to without union query?
that result from this:
to this:
please help me
[Updated on: Sun, 06 March 2016 23:17] Report message to a moderator
|
|
|
|
Re: row to column [message #648912 is a reply to message #648894] |
Mon, 07 March 2016 06:58 |
Solomon Yakobson
Messages: 3273 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
poppop wrote on Mon, 07 March 2016 00:16
how change this query to without union query?
Did you read documentation (link I posted)? Especially Pivoting on Multiple Columns.
SY.
|
|
|
Re: row to column [message #648933 is a reply to message #648912] |
Mon, 07 March 2016 16:21 |
Bill B
Messages: 1971 Registered: December 2004
|
Senior Member |
|
|
This is NOT an example of using the PIVOT command in Oracle. What version of the database are you using. Even if you do not have the PIVOT command available, you can easily do what you want using a single query. You did it the most expensive way you could. Once you give your database version, we can help you more.
|
|
|