Solved

doing math in a stored procedure

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

776 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