sqloracleoracle-sqldeveloperora-00918

Why am I getting error ORA-00918: Column ambiguously defined in Oracle SQL


I am running this statement and I am getting this error code: ora-00918 column ambiguously defined in Oracle SQL. I am not sure what I am missing here. Here is the statement:

SELECT NET_EQUITY, TOTAL_COMMISSION_CALC, TOTAL_TRADES, ADJUSTED_NET_EQUITY_CALC, PROCESS_DATE, SCORE, DESCRIPTION, ACCOUNT_NAME, ACCOUNT_NUMBER, INVESTMENT_OBJECTIVE_DESC
FROM SPAPP_OWNER.SP_ACCOUNT_PROFILE AP
INNER JOIN SPAPP_OWNER.SP_ACCOUNT_PRODUCT_PROFILE PP
ON AP.ACCOUNT_KEY=PP.ACCOUNT_KEY
INNER JOIN SPAPP_OWNER.SP_MODEL_DISTRIBUTION_DETAILS DD
ON PP.SEGMENT_KEY=DD.SEGMENT_KEY
INNER JOIN udmcds_owner.ACCOUNT A
ON AP.ACCOUNT_KEY=A.ACCOUNT_KEY
INNER JOIN udmcds_owner.ACCOUNT_INVESTMENT_OBJECTIVE AIO
ON A.TENANT_CD=AIO.TENANT_CD
WHERE PROFILE_DATE BETWEEN '31-JAN-22' AND '31-DEC-22'
AND TOTAL_TRADES >= 3
AND ADJUSTED_NET_EQUITY_CALC >= '100000.00'
AND TOTAL_COMMISSION_CALC > '1000.00'

Solution

  • Apparently one of the column names in your SELECT clause or in your WHERE clause is found in more than one of the tables you have joined together here. Fully qualify with alias prefixes every one of your column references in these clauses, just like you already have done with the join clauses.