Solved

Oracle Error Column Ambigously defined

Posted on 2014-11-12
3
274 Views
Last Modified: 2014-11-22
Why am I getting an error on this row

 WHERE PLAN_ID IN ('207')

"Column Ambigously Defined"



_________________________________________
SELECT
(Sum(case when STAT_C IN ('A') AND PCNT > 1 and DOL = 0 then 1 else 0 end)+Sum(case when STAT_C IN('A') AND PCNT < 1 and DOL > 0 then 1 else 0 end))/Sum(case when STAT_C IN('A') then 1 else 0 end) as PART_RATE
FROM(
SELECT SSN_N, FROM dbo.V_FDPAT

  LEFT JOIN(
      SELECT PLAN_ID, SSN_ID
         FROM dbo.V_FDPDF
           Group by PLAN_ID, SSN_ID
      ) C ON A.SSN_ID=C.SSN_ID AND  A.PLAN_ID=C.PLAN_ID

 WHERE PLAN_ID IN ('207')
and Row_Eff_D >= '31-Jul-14'
)
0
Comment
Question by:leezac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 15

Accepted Solution

by:
Haris Djulic earned 500 total points
ID: 40438728
Because you need to specify from which table you are referencing the column PLAN_ID is it A or C i.e.


SELECT
(Sum(case when STAT_C IN ('A') AND PCNT > 1 and DOL = 0 then 1 else 0 end)+Sum(case when STAT_C IN('A') AND PCNT < 1 and DOL > 0 then 1 else 0 end))/Sum(case when STAT_C IN('A') then 1 else 0 end) as PART_RATE
FROM( 
SELECT SSN_N, FROM dbo.V_FDPAT

  LEFT JOIN(
      SELECT PLAN_ID, SSN_ID
         FROM dbo.V_FDPDF
           Group by PLAN_ID, SSN_ID
      ) C ON A.SSN_ID=C.SSN_ID AND  A.PLAN_ID=C.PLAN_ID

 WHERE A.PLAN_ID IN ('207')
and Row_Eff_D >= '31-Jul-14'
)

Open in new window

0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40438761
>>and Row_Eff_D >= '31-Jul-14'

Not for points since Haris has answered the question.
I just wanted to encourage you to start doing explicit data type conversions and note rely on Oracle to 'guess'.

and Row_Eff_D >= to_date('31-Jul-14','DD-Mon-YY')
0
 

Author Closing Comment

by:leezac
ID: 40459506
Thank you!
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question