Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rating, avg, percentage..?

Status
Not open for further replies.

snowboardr

Programmer
Feb 22, 2002
1,401
PH
rate > 1 to 10

user comes in and votes.

How could I do the following?
Display rating for that user (7.335)

(Rank: #14350-88.2%)
Display number rank out of all users
Display % rank.. www.vzio.com
ASP WEB DEVELOPMENT



 
Hi snowboardr,

wouldn't the formatpercent function do that for you.
like
totalvotes
uservote = "whatever number"
then
totalPercent = FormatPercent(uservote/totalvotes,0)

am I close to what you wanted? A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
I'm not sure how general an answer you want to the "How to..". So I'll give a whole bunch of details and you can toss out the ones you don't need or want :)
Ratings:
Store the current rating and the number os people that have rated it. When someone adds a rating calculate the new rating by current_rating * current_num_people + new_rating / current_num_people
Then incrememnt the number of people by one.
The do an SQL select statement to count the number of records with rating > calculated rating.
The persons rating will be the calculated rating from above and the results of the SQL count + 1
-Tarwn "The problem with a kludge is eventually you're going to have to back and do it right." - Programmers Saying (The Wiz Biz - Rick Cook)
"Your a geek!" - My Girlfriends saying
 
Oh yeah, rank :p
You can get that with another select count for all records and the rank would be the rank count (sql count + 1 above) / total count from the statement to count all the records.
-Tarwn "The problem with a kludge is eventually you're going to have to back and do it right." - Programmers Saying (The Wiz Biz - Rick Cook)
"Your a geek!" - My Girlfriends saying
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top