Solved

doing math in a stored procedure

Posted on 2007-03-19
2
222 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

726 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