Hi this is my tables structure :
and this is my stored procedure :
GO
ALTER PROCEDURE [dbo].[uspGetVote](@TeamID INT,@CardID INT)
AS
BEGIN
select cast(avg(VoteValue) as float) as [AverageVoteValue] from Vote where datediff(day,getdate(),LastModifiedDateTime) <= 7 and TeamID = @TeamID and CardID=@CardID Group By TeamID,CardID order by AverageVoteValue
END
ALTER PROCEDURE [dbo].[uspGetVote](@TeamID INT,@CardID INT)
AS
BEGIN
select cast(avg(VoteValue) as float) as [AverageVoteValue] from Vote where datediff(day,getdate(),LastModifiedDateTime) <= 7 and TeamID = @TeamID and CardID=@CardID Group By TeamID,CardID order by AverageVoteValue
END
i want to join VoteComment Table also please give me a query for that
thank you

SivakumarPosted Sep 3, 2015, 8:09 AM
SivakumarPosted Sep 3, 2015, 7:53 AM
Column 'VoteComment.Comment' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
this is a procedure :
ALTER PROCEDURE [dbo].[uspGetVote](@TeamID INT,@CardID INT)
AS
BEGIN
select Comment,cast(avg(VoteValue) as decimal(8,2))as [AverageVoteValue] ,Comment from Vote inner join VoteComment on Vote.VoteId=VoteComment.VoteId where datediff(day,getdate(),LastModifiedDateTime) <= 7
and TeamID = @TeamID and CardID=@CardID Group By TeamID,CardID order by AverageVoteValue
END
Upendra Pratap ShahiPosted Sep 3, 2015, 6:56 AM
select cast(avg(VoteValue) as float) as [AverageVoteValue] from Vote inner join VoteComment on Vote.VoteId=VoteComment.VoteId where datediff(day,getdate(),LastModifiedDateTime) <= 7
and TeamID = @TeamID and CardID=@CardID Group By TeamID,CardID order by AverageVoteValue