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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -