ORA-00918: column ambiguously defined

Hi
Why am I getting the following error when all columns are prefixed with table names???
See Code for view definition

ORA-00918: column ambiguously defined
00918. 00000 -  "column ambiguously defined"
*Cause:    
*Action:
Error at Line: 32 Column: 18
CREATE OR REPLACE FORCE VIEW  xxkp_ctp_det_gr_v	 	(AU_SID
						 	,AU_ID
							,AU_NAME
							,ACTIVITY_ID
							,ACTIVITY_NAME
						 	,WORKGROUP_ID
                                                 	,WORKGROUP_NAME
						 	,USER_ID
						 	,USERNAME
						 	,FIRST_NAME
						 	,LAST_NAME
						 	,SUBJECT_COMPLETE
						 	,POSTASSESS_COMPLETE
							,BOTH_COMPLETE
						 	,SCORE
						 	,POSTASSESS_REQUIRED_SCORE
							,PASSED
							,XFAILED
							,NOT_STARTED
							,SUBJECT_IN_PROGRESS
							,POSTASSESS_IN_PROGRESS
						 	) 
AS 

SELECT		XXKP_CTP_DET_V.AU_SID
,		XXKP_CTP_DET_V.AU_ID
,		XXKP_CTP_DET_V.AU_NAME
,		XXKP_CTP_DET_V.ACTIVITY_NAME
,		XXKP_CTP_DET_V.WORKGROUP_ID
, 		XXKP_CTP_DET_V.WORKGROUP_NAME
, 		XXKP_CTP_DET_V.USER_ID
, 		XXKP_CTP_DET_V.USERNAME
, 		XXKP_CTP_DET_V.FIRST_NAME
, 		XXKP_CTP_DET_V.LAST_NAME
, 		COUNT(DISTINCT(XXKP_CTP_DET_V.ASSESS_RESULT_ID)) AS NO_OF_POSTASSESS_ATTEMPTS
,		CASE WHEN SUM(CASE WHEN XXKP_CTP_DET_V.SUBJECT_COMPLETE = 1 THEN 1 ELSE 0 END) > 0 
		THEN 1 ELSE 0 END AS SUBJECT_COMPLETE
, 		CASE WHEN SUM(CASE WHEN XXKP_CTP_DET_V.POSTASSESS_COMPLETE = 1 THEN 1 ELSE 0 END) > 0 
		THEN 1 ELSE 0 END AS POSTASSESS_COMPLETE
, 		CASE WHEN (CASE WHEN SUM(CASE WHEN XXKP_CTP_DET_V.SUBJECT_COMPLETE = 1 THEN 1 ELSE 0 END) > 0 
		THEN 1 ELSE 0 END) = 1 AND 
		(CASE WHEN SUM(CASE WHEN XXKP_CTP_DET_V.POSTASSESS_COMPLETE = 1 THEN 1 ELSE 0 END) > 0 
		THEN 1 ELSE 0 END) = 1 THEN 1 ELSE 0 END AS BOTH_COMPLETE
, 		CASE WHEN MAX(XXKP_CTP_DET_V.SCORE * 100) IS NULL THEN 0 ELSE MAX(XXKP_CTP_DET_V.SCORE * 100) END AS SCORE
, 		CASE WHEN MAX(XXKP_CTP_DET_V.POSTASSESS_REQUIRED_SCORE * 100) IS NULL 
		THEN 0 ELSE MAX(XXKP_CTP_DET_V.POSTASSESS_REQUIRED_SCORE * 100) END AS POSTASSESS_REQUIRED_SCORE
, 		CASE WHEN SUM(CASE WHEN XXKP_CTP_DET_V.PASSED = 1 THEN 1 ELSE 0 END) > 0 THEN 1 ELSE 0 END AS PASSED
,		CASE WHEN SUM(CASE WHEN XXKP_CTP_DET_V.PASSED = 1 THEN 1 ELSE 0 END) = 0 
		AND SUM(CASE WHEN XXKP_CTP_DET_V.XFAILED = 1 THEN 1 ELSE 0 END) > 0 THEN 1 ELSE 0 END AS XFAILED
, 		CASE WHEN SUM(CASE WHEN XXKP_CTP_DET_V.SUBJECT_COMPLETE_PERCENTAGE IS NULL THEN 0 ELSE 1 END) = 0 AND 
		(SUM(CASE WHEN XXKP_CTP_DET_V.SCORE IS NULL THEN 0 ELSE 1 END) = 0) THEN 1 ELSE 0 END AS NOT_STARTED
,		CASE WHEN SUM(XXKP_CTP_DET_V.SUBJECT_IN_PROGRESS) > 0 AND 
		(CASE WHEN SUM(CASE WHEN XXKP_CTP_DET_V.SUBJECT_COMPLETE = 1 THEN 1 ELSE 0 END) > 0 THEN 1 ELSE 0 END) <> 1 
		THEN 1 ELSE 0 END AS SUBJECT_IN_PROGRESS
, 		CASE WHEN SUM(XXKP_CTP_DET_V.POSTASSESS_IN_PROGRESS) > 0 AND 
		(CASE WHEN SUM(CASE WHEN XXKP_CTP_DET_V.POSTASSESS_COMPLETE = 1 THEN 1 ELSE 0 END) > 0 THEN 1 ELSE 0 END) <> 		1 THEN 1 ELSE 0 END AS POSTASSESS_IN_PROGRESS


FROM       	XXKP_CTP_DET_V
GROUP BY	XXKP_CTP_DET_V.AU_SID
, 		XXKP_CTP_DET_V.AU_ID
, 		XXKP_CTP_DET_V.AU_NAME
, 		XXKP_CTP_DET_V.ACTIVITY_NAME
, 		XXKP_CTP_DET_V.WORKGROUP_ID
, 		XXKP_CTP_DET_V.WORKGROUP_NAME
, 		XXKP_CTP_DET_V.USER_ID
, 		XXKP_CTP_DET_V.USERNAME
, 		XXKP_CTP_DET_V.FIRST_NAME
, 		XXKP_CTP_DET_V.LAST_NAME

/

EXIT

Open in new window

timpoynterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MilleniumaireCommented:
You will get this error when you reference a column that exists in more than one table.

Introduce a table alias and then qualify the column name with the alias.  This way you tell Oracle exactly which table the column should be taken from

e.g.

select t1.col,
          t2.col
from table1 t1,
        table 2 t2
0
neeraj523Commented:
prefix table name to all the columns referred in select statement
0
timpoynterAuthor Commented:
Hi

Thanks for the responses, but I am only querying one view and every column is prefixed (I think) please have a look at the code
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

neeraj523Commented:
try to run select statement only and see if it gives error.. if so, try to removing few parts of the query to debug the actual problem in it
0
timpoynterAuthor Commented:
I have its this element it doesn't like

CASE WHEN SUM(XXKP_CTP_DET_V.POSTASSESS_IN_PROGRESS) > 0 AND  
                (CASE WHEN SUM(CASE WHEN XXKP_CTP_DET_V.POSTASSESS_COMPLETE = 1 THEN 1 ELSE 0 END) > 0 THEN 1 ELSE 0 END) <>            1 THEN 1 ELSE 0 END AS POSTASSESS_IN_PROGRESS
 
As you can see everything is prefixed!

Any ideas???
0
MilleniumaireCommented:
You say you are querying a view.  Is it possible the view itself is causing the problem i.e. the view retrieves from multiple tables but isn't correctly prefixing the columns?
0
neeraj523Commented:
can check if this works for you

SELECT * FROM XXKP_CTP_DET_V
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
timpoynterAuthor Commented:
neeraj523

Thank you so much, when I did a select * I could see that there were an invalid number of columns of the view I was selecting from, fixed that and now the query works

Thanks
0
neeraj523Commented:
great to know that you were able to resolve the issue..

all the best
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.