您好我正在尝试在MySQL中创建一个视图,但我收到语法错误#1064,即
在这里我如何修复此变量问题任何解决方案或替代方法来轻松计算运行平衡
这是我的代码
SET @csum := 0;
SELECT
tblleasesalesschedule_details.LeaseSaleID,
tblleasesalesschedule_details.ScheduleSr,
tblleasesalesschedule_details.InstallmentName,
tblleasesalesschedule_details.InstallmentSr,
tblleasesalesschedule_details.ScheduleDate,
tblleasesalesschedule_details.Amount,
IFNULL(tblleasesalespayment.Amount, 0) AS AmountPaid,
(coalesce(tblleasesalesschedule_details.Amount, 0) - coalesce(tblleasesalespayment.Amount, 0)) As BalanceAmount,
(@csum := @csum + (coalesce(tblleasesalesschedule_details.Amount, 0) - coalesce(tblleasesalespayment.Amount, 0))) as RunningBalance,
tblleasesalespayment.PaymentDate
FROM
tblleasesalespayment
RIGHT JOIN tblleasesalesschedule_details ON tblleasesalesschedule_details.InstallmentSr = tblleasesalespayment.InstallmentSr
WHERE
tblleasesalesschedule_details.PayDate < NOW();