Solved

Oracle Error Column Ambigously defined

Posted on 2014-11-12
3
266 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.

Question has a verified solution.

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

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
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.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

832 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