Hi all,
We are modifying one of our db tables to include two fields, 'votes' and
'tally' for allowing to display a "rating" system. The 'votes' column will be a
running total of all votes, the 'tally' will be a column to hold the 'votes'
values. Example, if a person submits a vote of 3(with a range of 1-5), then we
would enter 1 in the 'votes' column and 3 in the 'tally' column. Another person
comes along and votes, they submit a 4. Now we have 2 in the 'votes' column and
7 in the 'tally' column, another person comes along and votes a 4, now we have 3
in the 'votes' and 11 in the 'tally'... and so on.
In the table columns:
votes tally
*-----|------*
3 11
*-----|------*
Now we want to display our rating. What I need to do is take the tally divide it
by the number of votes = 3.67 Now can we do this with a SQL query in MySQL and
have it work, something like this:
ROUND((tally / votes),2) AS Rating
which I believe should give me 4...correct?? or would it better to do the
calculations within the script after extracting the column data ??
Mike(mickalo)Blezien
========================================
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
Tel: 1(225) 686-2002
=========================================
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php