ORA-00918 on UNIONS [message #218548] |
Thu, 08 February 2007 10:57  |
cshamoh
Messages: 5 Registered: February 2007
|
Junior Member |
|
|
Guys,
Im getting strange things here.
Im doing some ETL prototype for Siebel reporting.
There is fact table, dim tables, aggregation calculations etc.
Thing is that Im getting this nasty 'ORA-00918: column ambiguously defined error' nomatter what I do on making final UNIONs on 4 views.
SELECT *
FROM ((SELECT a.PROD_ID_A, a.CUST_ID_A, a.GEO_ID_A, a.TIME_ID_A, a.FACT_AMT_2_CORR_LOW_A, a.FACT_AMT_2_CORR_HIG_A, a.SKU_FACT_AMT_2_A, a.FACT_AMT_2_INDEX_A, a.FACT_AMT_2_INDEX_STATUS_A FROM pp_np_cmp_cn_amt2_lm_v a
UNION
SELECT b.PROD_ID_C, b.CUST_ID_C, b.GEO_ID_C, b.TIME_ID_C, b.FACT_AMT_2_CORR_LOW_C, b.FACT_AMT_2_CORR_HIG_C, b.SKU_FACT_AMT_2_C, b.FACT_AMT_2_INDEX_C, b.FACT_AMT_2_INDEX_STATUS_C FROM pp_np_cmp_cn_amt2_l3m_v b)
UNION
(SELECT c.PROD_ID_E, c.CUST_ID_E, c.GEO_ID_E, c.TIME_ID_E, c.FACT_AMT_2_CORR_LOW_E, c.FACT_AMT_2_CORR_HIG_E, c.SKU_FACT_AMT_2_E, c.FACT_AMT_2_INDEX_E, c.FACT_AMT_2_INDEX_STATUS_E FROM pp_np_cmp_cn_amt2_l6m_v c
UNION
SELECT d.PROD_ID_G, d.CUST_ID_G, d.GEO_ID_G, d.TIME_ID_G, d.FACT_AMT_2_CORR_LOW_G, d.FACT_AMT_2_CORR_HIG_G, d.SKU_FACT_AMT_2_G, d.FACT_AMT_2_INDEX_G, d.FACT_AMT_2_INDEX_STATUS_G FROM pp_np_cmp_cn_amt2_fytd_v d));
Strange thing is that when Im doing UNION for any (any combination) of those 3 selects - it works, but as I add 4th it fails.
I tried everything - tables aliases, renaming columns with 'AS' etc. Still the same...
Thanx for saving my project 
Cshamoh
[Updated on: Thu, 08 February 2007 10:59] Report message to a moderator
|
|
|
Re: ORA-00918 on UNIONS [message #218568 is a reply to message #218548] |
Thu, 08 February 2007 13:11   |
smartin
Messages: 1803 Registered: March 2005 Location: Jacksonville, Florida
|
Senior Member |
|
|
What happens if you get rid of all of the parenthesis and the outer select * from? Logically, union really doesn't have an order of precedence, because union says take them all.
|
|
|
|
|
|
|