[mysql] "order by" question [solved]

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
bytte
Forum Commoner
Posts: 75
Joined: Sun Nov 23, 2003 8:20 am
Location: Belgium

[mysql] "order by" question [solved]

Post by bytte »

Hi,
I have a database table called music.
It stores information about mp3's that users can post.
Users can also rate the mp3's.

Therefor i have a column called score and a column called score_number.

Score is the sum of all points an mp3 gets when someone rates it.
score_number is the amount of people that rated the mp3.

to know the rating of a song i divide score by score_number.


Now I want users to be able to select the songs by rating. So the top rated songs should appear first. How can I do this with an ORDER BY statement? I can't do this can i?:

"SELECT * FROM music ORDER BY score/score_number"
Last edited by bytte on Sun Feb 15, 2004 9:04 am, edited 1 time in total.
bytte
Forum Commoner
Posts: 75
Joined: Sun Nov 23, 2003 8:20 am
Location: Belgium

Post by bytte »

i just found out that i actually can do this query.
haha. i didn't know. sorry.
Post Reply