Reputation: 29925
Ok, title is a bit dodgy.
I'm having trouble with combining mysql and maths at the moment. Can someone help me, I'm guessing its pretty simple. Sorry if its really easy!
What I want to get is a record as a percentage of the total of all records.
The application is pages in a CMS. They each have a page views field which is incremented for each page view.
I need to get that page's page views as a percentage of the total page views over the whole site.
How would I do this?
Thank you.
Upvotes: 0
Views: 211
Reputation: 3454
select pageviews * 100 / (select sum(pageviews) from table) from table where page_id = 42
Upvotes: 3