I have extracted browser records from access log file and inserted them into database.Now i need to display the most popular browsers and their percentages too so i need a query for that.Here is how the records look like:
Mozilla/5.0 (compatible; AhrefsBot/5.0; + http://ahrefs.com/robot/ )
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0
Opera/9.80 (Windows NT 6.1) Presto/2.12.388 Version/12.16
In the results table i want to show only browser/version without specifications in the brackets above and i need percentage too.
I have tried to use (count(distinct client)/sum(distinct client)*100) to calculate the percentage but it returns NULL.Can anyone help?
You can use like
filter to extract the particular browser count. For ex. to get count for mozilla:
select (select count(*) from table_name where column_name like '%Mozilla%' count_mozilla)/(select count(*) from table_name total_count)*100 from dual
Hope it helps.. :)
Can you not do something like:
Select count(*) as count_of_browser_use, browser_type from stats_table Group by browser_type
Then just use PHP (or other language) to quickly do the maths?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.