gpt4 book ai didi

php - mysql中的函数(1064错误)

转载 作者:可可西里 更新时间:2023-11-01 07:44:59 24 4
gpt4 key购买 nike

<分区>

查询

CREATE FUNCTION AverageRateofProduct
( p_toDate datetime, p_productBatchId longtext )
RETURNS decimal(18,2)
BEGIN

Declare p_averageRate decimal(18,2) ;

if((SELECT IFNULL(sum(inwardQuantity),0) FROM tbl_StockPosting WHERE (date < p_toDate and productBatchId =p_productBatchId))>0)
then
set p_averageRate =
select IFNULL(sum((inwardQuantity * rate)/sum(inwardQuantity)),0)
from tbl_StockPosting where (date < p_toDate and productBatchId =p_productBatchId) ;
END if;

return IFNULL(p_averageRate,0) ;
end

在第 11 行给出错误 1064。

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds to your MySQL server version for the right syntax to use near 'select IFNULL(sum((inwardQuantity * rate)/sum(inwardQuantity)),0)                                                        fro' at line 11

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com