valtido Posted July 29, 2008 Share Posted July 29, 2008 Hi i have to columnt e.g. "NumberOfHits" and "points"... im looking to select the record and order them by the difference between the two e.g. "SELECT * FROM users ORDER BY average(points,numberOfHits) DESC LIMIT 10"; is there away to do this? to order them by those who have a higher average number.x Link to comment https://forums.phpfreaks.com/topic/117193-solved-mysql-order-by-help-plz/ Share on other sites More sharing options...
obsidian Posted July 29, 2008 Share Posted July 29, 2008 "Difference between the two" implies that you are subtracting one from the other. If this is the case, you may be able to get by with this: SELECT *, (points - numberOfHits) AS diff FROM users ORDER BY diff DESC LIMIT 10; Link to comment https://forums.phpfreaks.com/topic/117193-solved-mysql-order-by-help-plz/#findComment-602811 Share on other sites More sharing options...
valtido Posted July 29, 2008 Author Share Posted July 29, 2008 if i want to find the average between the two then i would have to divide points by hits gives me the average, but that gives me irregular order... Link to comment https://forums.phpfreaks.com/topic/117193-solved-mysql-order-by-help-plz/#findComment-602821 Share on other sites More sharing options...
valtido Posted July 29, 2008 Author Share Posted July 29, 2008 I think i have solved it lol thank u v much Link to comment https://forums.phpfreaks.com/topic/117193-solved-mysql-order-by-help-plz/#findComment-602825 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.