I want to update the LOANS.STATUS = 'PAID'
IF SUM(PAYMENT_AMOUNT) >= LOAN_AMOUNT WHERE LOANS.EMPID=PAYMENTS.EMPID
AND LOANS.LOAN_TYPE=PAYMENTS.LOAN_TYPE
can you help me the syntax pls....thanks
Behind The Success And Failure Of A Man Is A Woman
update loans l
set l.status = 'PAID'
where l.loan_mount <=
(
select sum(p.payment_amount)
from payments p
where l.empid = p.empid
and l.loan_type = p.loan_type
group by p.empid,p.loan_type
)
;
Note: Code was not tested, sorry, have real work on my plate
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
I want to update the LOANS.STATUS = 'PAID WITHIN REQUIRED TERMS'
IF (LAST PAYMENT_DATE - LOAN_DATE) <= PAYMENT_TERM
WHERE LOANS.EMPID=PAYMENTS.EMPID
AND LOANS.LOAN_TYPE=PAYMENTS.LOAN_TYPE
can you help me the syntax pls....thanks
Last edited by yxez; 07-26-2007 at 12:31 PM.
Behind The Success And Failure Of A Man Is A Woman
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
update loans l set l.status='PAID WITHIN REQUIRED TERMS'
where l.payment_term>=
(select max(p.payment_date)
from payment p
where l.empid = p.empid
and l.loan_type = p.loan_type
- l.loan_date )
;
Behind The Success And Failure Of A Man Is A Woman
1- You cannot compare a number like payment_term with a date like payment_date.
The first term of your predicate should be a date like (loan_date + payment_term)
2- You can't substract a date like loan_date from a varchar like loan_type; actually not sure why you added that "- l.loan_date" at the end of your predicate, just take it away.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Bookmarks