I searched the forums and I have seen questions similiar to the one I am asking, but its not the exact same issue.
I need 3 fields in my 'for' clause. I get 'column ambiguously defined. I think I get this error for a different reason that other people asking the question.
The others seem to be doing more than 1 function in the pivot clause and those need an alias. I give an alias with my 1 function and still get an error.
ORA-00918: column ambiguously defined
I used aliases like the recommendation in other posts and I still get the same error. I think I need 3 columns in the for clause.
--note that this is just a test table. These are not real names going into production
create table pivot_tab (
pk1 number,
pk2 number,
myElement varchar2(30),
myElementDate date);
pk1,pk2 are the unique key.
I need this to return as: the vlaues after pk2, can be any alias. This is just an example.
pk1 pk2 MY1_DATE, MY2_DATE, MY3_DATE
select *
from pivot_tab
PIVOT ( max(myElementDate) for myElement
in (''MY1','MY2','MY3'))
I saw a couple of references to this syntax, but I get syntax errors.
ora--00906: missing parentheses. So I dont think this syntax works.
select *
from pivot_tab
PIVOT ( max(myElementDate) for (pk1,pk2,myElement)
in (''MY1','MY2','MY3'))
Edited by: Guess2 on May 6, 2013 6:50 AM