I can't see how CASE works ?? Manual is fairly breif on the subject.

The SQL below has some kind of snag. Is this getting too hairy to use CASE within a sum
expression ?? Any thoughts or comments would be appreciated.


 SELECT Sum(DebtorTrans.OvAmount + DebtorTrans.OvGST +
 DebtorTrans.OvFreight -
 DebtorTrans.OvDiscount - DebtorTrans.Alloc) AS Balance,
Sum(
CASE WHEN (TO_DAYS(Now()) - TO_DAYS(DebtorTrans.TranDate)) >= 10
THEN DebtorTrans.OvAmount + DebtorTrans.OvGST + DebtorTrans.OvFreight -
DebtorTrans.OvDiscount - DebtorTrans.Alloc
ELSE 0
END) AS 10DaysOld,
FROM DebtorTrans
WHERE DebtorTrans.DebtorNo = 'CARLYL'


 MySQL said: You have an error in your SQL syntax near 'WHEN
 (TO_DAYS(Now()) - TO_DAYS(DebtorTrans.TranDate)) >= 10 THEN DebtorTrans.Ov'
 at line 2


 TIA
Phil Daintree


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to