jck Posted July 16, 2007 Share Posted July 16, 2007 suppose in a table there are ratesum and ratecount and rating is ratesum/ratecount how do i sort them in descending order of rating Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 16, 2007 Share Posted July 16, 2007 <?php $q = "SELECT * FROM Table ORDER BY sum(ratesum/ratecount)"; ?> Quote Link to comment Share on other sites More sharing options...
jck Posted July 16, 2007 Author Share Posted July 16, 2007 what isĀ sum(ratesum/ratecount) Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 16, 2007 Share Posted July 16, 2007 $q = "SELECT ratesum, ratecount FROM Table ORDER BY rating"; Ā is that what you mean? Quote Link to comment Share on other sites More sharing options...
jck Posted July 16, 2007 Author Share Posted July 16, 2007 there is no field for rating in the table ecause it is not storing decimals so on the pages its dynamically calculated so i need to order by ratesum divided by ratecount Quote Link to comment Share on other sites More sharing options...
jck Posted July 16, 2007 Author Share Posted July 16, 2007 stored as float Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 SELECT ratesum/ratecount AS rating FROM Table ORDER BY rating; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.