Click here to Skip to main content
15,900,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 :
SQL
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
Posted
Updated 2-Sep-15 23:46pm
v2

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:
SQL
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.
 
Share this answer
 
SQL
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900