I'm trying to create an SQL query to work out the percentage of rows given its number of play counts.
My DB currently has 800 rows of content, All content has been played a total of 3,000,000 times put together
table: id, play_count, content
Lets say I'd like to work out the percentage of the first 10 rows.
My attempts have looked similar to this:
SELECT COUNT(*) AS total_content,
SUM(play_count) AS total_played,
content.play_count AS content_plays
FROM bebo_video
How would I put this all together to show a final p开发者_开发知识库ercentage on each individual row??
SELECT play_count / (SELECT SUM(play_count) FROM bebo_video) * 100 FROM bebo_video
Use ROUND, TRUNCATE, etc. to format the resulting values.
精彩评论