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 Link to comment https://forums.phpfreaks.com/topic/60126-solved-descending-order-of-rating/ 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)"; ?> Link to comment https://forums.phpfreaks.com/topic/60126-solved-descending-order-of-rating/#findComment-299111 Share on other sites More sharing options...
jck Posted July 16, 2007 Author Share Posted July 16, 2007 what is sum(ratesum/ratecount) Link to comment https://forums.phpfreaks.com/topic/60126-solved-descending-order-of-rating/#findComment-299117 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? Link to comment https://forums.phpfreaks.com/topic/60126-solved-descending-order-of-rating/#findComment-299119 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 Link to comment https://forums.phpfreaks.com/topic/60126-solved-descending-order-of-rating/#findComment-299121 Share on other sites More sharing options...
jck Posted July 16, 2007 Author Share Posted July 16, 2007 stored as float Link to comment https://forums.phpfreaks.com/topic/60126-solved-descending-order-of-rating/#findComment-299130 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; Link to comment https://forums.phpfreaks.com/topic/60126-solved-descending-order-of-rating/#findComment-299148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.