PDA

View Full Version : Can you order by (field1 / field2)



Magic2K2
August 1st, 2001, 08:14
I have a basketball site and it is necessary for me to calculate (points / games). Right now I do not have a field in the DB for that number. I only have individual fields for points and games. I'd like to avoid adding another field if possible, but I need to order by (points / games). Is this possible?

If it's not, what do you recommend? I am thinking that I would either go ahead and add the field (length of 4 on over 300 records) or write some code to store the information and then sort it myself.

!ben
August 1st, 2001, 09:41
in mySQL you can simply have:


select * from tablename order by field1 / field2 desc

Magic2K2
August 16th, 2001, 19:22
Originally posted by !ben
in mySQL you can simply have:


select * from tablename order by field1 / field2 desc

Weird. That was working when I tried it a while ago, but now I get:


SELECT * FROM nba_player_stats ORDER BY points / games LIMIT 0, 30

MySQL said: You have an error in your SQL syntax near '/ games LIMIT 0, 30' at line 1

Magic2K2
August 16th, 2001, 19:28
Well, it worked on f2s, but I need it to work on ValuableHost where I'm at now. I suppose it's a server thing and I need to contact them.