Mysql
 sql >> Database >  >> RDS >> Mysql

Ottenere una percentuale da MySql con un gruppo per condizione e precisione

Primo numero:

select count(*) from agents into @AgentCount;

SELECT user_agent_parsed
     , user_agent_original
     , COUNT( user_agent_parsed )  AS thecount
     , COUNT( * ) / ( @AgentCount) AS percentage
 FROM agents
GROUP BY user_agent_parsed
ORDER BY thecount DESC LIMIT 50;