Solved

doing math in a stored procedure

Posted on 2007-03-19
2
190 Views
Last Modified: 2007-03-19
I have a table called PGRating.  I want to be able to add the values in the Rating column all together and then take an average of that.  in plain english, here is the formula:

select (Sum of all Rating values) / (count of rows)
from PGRating
where PGImageID = @PGImageID
0
Comment
Question by:attipa
2 Comments
 
LVL 42

Accepted Solution

by:
dqmq earned 500 total points
ID: 18754401
you almost have it.
select avg(ratingvalue) from pgrating where pgimageID = @pgimagID
0
 
LVL 6

Expert Comment

by:chiragkhabaria
ID: 18754410
Select Sum(Rating)/
(Select Count(1) From PGRating)
From PRGRating
Where PGImageID = @PGImageID
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now