DELIMITER //
CREATE PROCEDURE GetAllData()
BEGIN
DECLARE execPrice DOUBLE;
SET execPrice = sum(LastQty * LastPx) / sum(LastQty);
select
execPrice as avgExedPrc,
sum((LastQty * LimitPrice)) / sum(LastQty) as avgOrdPrc,
无法使用变量execPrice。 有人可以帮忙。
答案 0 :(得分:0)
sum()
仅用于查询,因为它总计1行或更多行。
在这里,你甚至没有任何可以总结的东西:
SET execPrice = sum(LastQty * LastPx) / sum(LastQty);
将其更改为
SET execPrice = LastQty * LastPx / LastQty;