你好,我想創建MySQL中的觀點,但我得到語法錯誤#1064即MySQL的運行平衡查看錯誤
1064 - 你在你的SQL語法錯誤;請檢查與您的MySQL服務器版本對應的手冊,以便在「SET @csum:= 0;」附近使用正確的語法。在3號線
在這裏,我怎麼能解決這個變量問題的任何解決方案或替代的方法來計算輕鬆
這裏運行平衡是我的代碼
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();
要創建一個assing變種風景嗎? 。顯示所有的代碼請 – scaisEdge
是的,但我不確定在視圖中,我們可以指定變量或不是這是我有的完整代碼,實際上我使用的是navicat preimum – DUbaicos