#1111 - 存储过程mysql中使用组函数错误无效

时间:2014-07-25 08:57:40

标签: mysql stored-procedures

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。 有人可以帮忙。

1 个答案:

答案 0 :(得分:0)

sum()仅用于查询,因为它总计1行或更多行。

在这里,你甚至没有任何可以总结的东西:

SET execPrice = sum(LastQty * LastPx) / sum(LastQty);

将其更改为

SET execPrice = LastQty * LastPx / LastQty;
相关问题