sql check please

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

SELECT SUM (care_charges + other_charges + Pay_late_fee_daily + pickup_late_fee_minute + payment_amount)
FROM payments
WHERE ID = MMColParam AND year(payment_duedate) < year(now()) AND year(other_charges_date) < year(now()) AND year(pay_late_fee_date)
< year(now()) AND year(payment_date) < year(now()) AND year(pickup_late_fee_date) < year(now())

this use to pick up all the right info... now it picks up nothing
any ideas?
thanks!
 
If any of the fields contain a Null value, the sum is going to be a Null.

See whether the following works any better:

SELECT SUM (Nz(care_charges, 0) + Nz(other_charges, 0) +
Nz(Pay_late_fee_daily, 0) + Nz(pickup_late_fee_minute, 0) +
NZ(payment_amount, 0))
FROM payments
WHERE ID = MMColParam AND year(payment_duedate) < year(now()) AND
year(other_charges_date) < year(now()) AND year(pay_late_fee_date)
< year(now()) AND year(payment_date) < year(now()) AND
year(pickup_late_fee_date) < year(now())
 
Back
Top