我有一个存储过程,我想对空列进行平均。
这是我的存储过程:
SELECT
AVG(planned) AS Planned,
AVG(achieved) AS Achieved
FROM
Port
INNER JOIN
Technology ON Port.portID = Technology.portRef
我使用数据源将此存储过程绑定(bind)到图表,当该列为空时,C# 代码抛出此错误:
Value was either too large or too small for a Decimal.
如何处理我的存储过程以avg
那些空列?
最佳答案
当查询没有返回任何值时会发生这种情况。用这个
SELECT
coalesce(avg(planned),0) as Planned,
coalesce(avg(achieved),0) as Achieved
FROM
Port inner join Technology on Port.portID = Technology.portRef
关于c# - 平均存储过程中的空列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11466609/