Solved

Oracle Error Column Ambigously defined

Posted on 2014-11-12
3
257 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
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 76

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now