?
Solved

doing math in a stored procedure

Posted on 2007-03-19
2
Medium Priority
?
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 42

Accepted Solution

by:
dqmq earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

801 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