开发者

Get numerical value as a percentage of total of all rows

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 pe开发者_如何学运维rcentage of the total page views over the whole site.

How would I do this?

Thank you.


select pageviews * 100 / (select sum(pageviews) from table) from table where page_id = 42

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜