uramagget Posted January 20, 2008 Share Posted January 20, 2008 I want to make a top 5 for a little mods script I downloaded, but in order to be an overall part of the top 5, a mod has to be high in each: # of Downloadeds # of Installs Marked # of Views # of Comments Though the Math and performing the SQL query is just complicated. I do not know if there is further information to provide, but if there is, please tell me. Quote Link to comment https://forums.phpfreaks.com/topic/86949-solved-selecting-overall-top-5/ Share on other sites More sharing options...
Barand Posted January 20, 2008 Share Posted January 20, 2008 Add the four together and sort in descending order of the total. Quote Link to comment https://forums.phpfreaks.com/topic/86949-solved-selecting-overall-top-5/#findComment-444544 Share on other sites More sharing options...
GingerRobot Posted January 20, 2008 Share Posted January 20, 2008 You may also wish to multiply by a weighting factor. For example, you may consider that views are less important than the other factors. The query would be something like: SELECT (downloads+installs+views*0.5+comments) as total FROM table ORDER BY total DESC Quote Link to comment https://forums.phpfreaks.com/topic/86949-solved-selecting-overall-top-5/#findComment-444575 Share on other sites More sharing options...
uramagget Posted January 21, 2008 Author Share Posted January 21, 2008 Thank you Gingerbot, though I'd like to know one thing though. Do I replace the total with something? Also, my comments are located in another table, for the sake of organization. How would I add something from another table? Quote Link to comment https://forums.phpfreaks.com/topic/86949-solved-selecting-overall-top-5/#findComment-445273 Share on other sites More sharing options...
GingerRobot Posted January 21, 2008 Share Posted January 21, 2008 Question 1.) No. Question 2.) You'll need to join the tables. Lets say you have a field called id in both, which the join can be performed on. Lets also say downloads and installs are in table1 and views and comments are in table2: SELECT (table1.downloads+table1.installs+table2.views*0.5+table2.comments) as total, table1.id as id FROM table1,table2 WHERE table1.id=table2.id ORDER BY total DESC Quote Link to comment https://forums.phpfreaks.com/topic/86949-solved-selecting-overall-top-5/#findComment-445302 Share on other sites More sharing options...
uramagget Posted January 22, 2008 Author Share Posted January 22, 2008 Ah, I get it. Thank you very much, GingerRobot. Quote Link to comment https://forums.phpfreaks.com/topic/86949-solved-selecting-overall-top-5/#findComment-445706 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.