Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Oracle Error Column Ambigously defined

Posted on 2014-11-12
3
Medium Priority
?
280 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 2000 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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

688 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