dreamwest Posted February 17, 2009 Share Posted February 17, 2009 I need to divide one column with another and sort a value of 5 DESC Original code: $sql = "SELECT * FROM rank ORDER BY total_value DESC "; Now i need to divide 2 columns - total_value and total_count, then ORDER by 5 DESC What ive come up with so far: $sql = "SELECT * FROM rank ORDER BY (total_value/total_count) DESC "; (total_value/total_count) will always produce 5 or less Link to comment https://forums.phpfreaks.com/topic/145550-solved-subtract-in-order-by/ Share on other sites More sharing options...
fenway Posted February 17, 2009 Share Posted February 17, 2009 So, what's wrong with that? Link to comment https://forums.phpfreaks.com/topic/145550-solved-subtract-in-order-by/#findComment-764140 Share on other sites More sharing options...
dreamwest Posted February 17, 2009 Author Share Posted February 17, 2009 Your right it works. Didn't think you could divide to columns values against each other within a query Link to comment https://forums.phpfreaks.com/topic/145550-solved-subtract-in-order-by/#findComment-764167 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.