Link to home
Start Free TrialLog in
Avatar of leezac
leezac

asked on

Missing Right Parenthesis Oracle SQL

I am getting an error "Missing Right Parenthesis"  on this line.        ) C ON A.PLAN_ID=C.PLAN_ID AND A.SSN_ID=C.SSN_ID  

 I can't figure why - it looks like all of them are there.


____________________________________________________________________________________________


SELECT PLAN_N, PLAN_SHRT_NM, DVSN_NM, C.Plan_ID,
   SUM(Case when BAL>0 THEN Balance Else 0 end) as "Assets"
        FROM(
      SELECT A.PLAN_ID, PLAN_N, PLAN_SHRT_NM, SUM(END_ASET_BAL_A)as BAL
      FROM dbo.V_BAL_MO A      
         
          LEFT JOIN(
                SELECT
               (Sum(case when STAT_C IN ('A') AND PCNT > 1 and DEF_DOL = 0 then 1 else 0 end)
               +Sum(case when STAT_C IN('A') AND PCNT < 1 and DEF_DOL > 0
               then 1 else 0 end))/Sum(case when STAT_C IN('A')
               then 1 else 0 end) as RATE
                ,NVL(ROUND(AVG(CASE when STAT_C IN ('A')
                AND PCNT > 1 THEN PCNT end),2),0) as DRATE
          FROM(
             SELECT PlanID, NVL(DEF_A,0) as DEF_DOL, NVL(DEF_P,0) as PCNT, SSN_ID, STAT_C
             FROM dbo.V_PART
             WHERE row_exp_d=TO_DATE('01/01/9999','MM/DD/YYYY')
             AND PLAN_ID IN ('207')
             ) C ON A.PLAN_ID=C.PLAN_ID AND A.SSN_ID=C.SSN_ID  

) GROUP BY PLAN_N, PLAN_SHRT_NM, DVSN_NM
SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of leezac
leezac

ASKER

I get other errors adding more parenthesis.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of leezac

ASKER

I did not write the code and may post the complete code to get help.  I am not a SQL guru and can use all the help I can get.  The code can probably be rewritten to be more efficient.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of leezac

ASKER

I appreciate comments.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of leezac

ASKER

Oracle SQL
>>Oracle SQL

I do not know what this is trying to tell me.
Avatar of leezac

ASKER

I've requested that this question be closed as follows:

Accepted answer: 0 points for leezac's comment #a40448694
Assisted answer: 84 points for Jim Horn's comment #a40443436
Assisted answer: 84 points for Racimo's comment #a40443604
Assisted answer: 83 points for slightwv's comment #a40443632
Assisted answer: 83 points for markgeer's comment #a40443703
Assisted answer: 83 points for slightwv's comment #a40443858
Assisted answer: 83 points for slightwv's comment #a40448635

for the following reason:

Thank you!
Avatar of leezac

ASKER

Thank you!