我执行我的存储过程时得到相同的平均值 [英] iam getting same average values when execute my stored procedure

查看:80
本文介绍了我执行我的存储过程时得到相同的平均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



Iam在执行存储过程时得到相同的平均值。



i传递不同的TeamID但得到相同的平均值

Hi
Iam Getting same average values when i execute my stored procedure.

i passing different TeamID's but Getting same Average values

this is my stored procedure :

GO
/****** Object:  StoredProcedure [dbo].[uspGetVote]    Script Date: 9/3/2015 12:40:42 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[uspGetVote](@TeamID INT)

AS

BEGIN


select avg(VoteValue) as [AverageVoteValue] from Vote  where datediff(day,getdate(),LastModifiedDateTime) <= 7 Group By TeamID order by AverageVoteValue

END



请给我一个正确的查询。



谢谢


Please give me a correct query for that.

Thank You

推荐答案

你不是'使用你传入的参数值,所以我怀疑它返回了所有TeamId的平均值 - 你可能想要这个:

You aren't using the parameter value you pass in so I suspect it is returning the average values for all TeamId's - it's possible you want this:
SELECT AVG(VoteValue) AS [AverageVoteValue] 
FROM Vote 
WHERE datediff(day,getdate(),LastModifiedDateTime) <= 7
AND TeamID = @TeamID
ORDER BY AverageVoteValue



但是如果没有你的数据并且想知道你想要得到什么,就很难确定。


But without your data and a better idea of exactly what you want to get, it's difficult to be sure.


based on you'r SP i'm excepecting you need to get avg values for Given Team ID

please check below Query

select avg(VoteValue) as [AverageVoteValue] from Vote where datediff(day,getdate(),LastModifiedDateTime) <= 7 and TeamID = @TeamID  Goup By TeamID order by AverageVoteValue



if it's not please write your requirement.


这篇关于我执行我的存储过程时得到相同的平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆