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 Quote 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? Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.