Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

doing math in a stored procedure

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
attipa
Asked:
attipa
1 Solution
 
dqmqCommented:
you almost have it.
select avg(ratingvalue) from pgrating where pgimageID = @pgimagID
0
 
chiragkhabariaCommented:
Select Sum(Rating)/
(Select Count(1) From PGRating)
From PRGRating
Where PGImageID = @PGImageID
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now