I am trying to transpose columns to rows using query similar to the following...
WITH
query AS
(
SELECT SYSDATE AS SomeDate,
'One' AS One,
'Two' AS Two,
'Three' AS Three,
'Four' AS Four,
'Five' AS Five
FROM dual
),
up_query AS
(
SELECT *
FROM query
UNPIVOT
(
NUM FOR DUMMY
IN
(
One AS 'One',
Two AS 'Two',
Three AS 'Three',
Four AS 'Four',
Five AS 'Five'
)
)
)
SELECT SYSDATE, b.*
FROM up_query b;
I was expecting SomeDate to reflect SYSDATE for the resulting rows... But this is the result I am getting:
SYSDATE SOMEDATE DUMMY NUM
09-DEC-11 09-DEC-07 One One
09-DEC-11 09-DEC-07 Two Two
09-DEC-11 09-DEC-07 Three Three
09-DEC-11 09-DEC-07 Four Four
09-DEC-11 09-DEC-07 Five Five
Why is the SOMEDATE 4 years earlier than SYSDATE?