Reputation: 305
I get this error for the below query when I am trying to make a left outer join
ERROR at line 7: ORA-00936: missing expression
select s.FINAL_BSAL,s.EMP_No,p.ERN_DDCT_CATNO,p.AMOUNT,n.NO_PAY_AMOUNT,
p.Pay_month,a.ARREARS_AMOUNT from salary_details s,pay_details p,Arrears a,No_Pay n
where s.emp_no=p.emp_no
and
s.SAL_NO IN (SELECT MAX(SAL_NO) FROM SALARY_DETAILS group by EMP_NO)
AND
to_char(P.PAY_MONTH,'MM-YYYY') =to_char(n.NO_PAY_MONTH,'MM-YYYY') (+)
AND
to_char(P.PAY_MONTH,'MM-YYYY')=to_char(a.ARREARS_MONTH,'MM-YYYY') ;
Please help.
Upvotes: 0
Views: 1215
Reputation: 23588
The issue lies with the placement of (+)
:
Instead of:
to_char(P.PAY_MONTH,'MM-YYYY') =to_char(n.NO_PAY_MONTH,'MM-YYYY') (+)
you should do:
to_char(P.PAY_MONTH,'MM-YYYY') =to_char(n.NO_PAY_MONTH (+),'MM-YYYY')
However, if I were you, I'd go with @Walter_Ritzel's approach and use ANSI JOIN syntax instead. That and properly format the SQL so that it's readable...
Upvotes: 3
Reputation: 1397
Try this:
select s.FINAL_BSAL
,s.EMP_No
,p.ERN_DDCT_CATNO
,p.AMOUNT
,n.NO_PAY_AMOUNT
,p.Pay_month
,a.ARREARS_AMOUNT
from salary_details s inner join pay_details p on s.emp_no = p.emp_no
inner join Arrears a on to_char(P.PAY_MONTH,'MM-YYYY')= to_char(a.ARREARS_MONTH,'MM-YYYY')
left outer join No_Pay n on to_char(P.PAY_MONTH,'MM-YYYY') = to_char(n.NO_PAY_MONTH,'MM-YYYY')
where s.SAL_NO IN (SELECT MAX(SAL_NO) FROM SALARY_DETAILS group by EMP_NO);
Upvotes: 1