How to return the calculated (aggregated) result of a SQL Server stored procedure -
i'm trying write stored procedure return number (an average) - have far...
alter procedure [dbo].[sp_getaveragerating] @recipenodeid int set nocount on; (select sum(rating) ratingtotal dbo.reciperating recipenodeid = @recipenodeid) (select count(rating) ratingentries dbo.reciperating recipenodeid = @recipenodeid)
so works , gives me
a.) rating total
b.) number of rating entries
i want return rating total / rating entries stored procedure.
can me syntax please?
just use avg function:
select avg(rating) ratingtotal dbo.reciperating recipenodeid = @recipenodeid
Comments
Post a Comment