I'm trying to get the percentage of each video I have in my database based on its view count against all other videos.
I'm then trying to display all the videos from highest view count to lowest, displaying its percentage on its side inside a nice HTML page.
Obviously the percentage would range from 0 - 100% (and not over) and the most popular video would probably have 100% I assume..
I have about 3,400 videos in the database. My attempts are laughable and have been scratching my head for about days now..
My table looks something similar to this.
video_public
*id, video_title, video_views*
Attempt:
SELECT id, video_views * 100 / (SELECT COUNT(*) FROM video_public) FROM
video_public
stat
To be honest I don't even know if this SQL query is right.
I haven't even taken into consideration the videos views against all video views and total videos..
Really stuck..