Which of my campaigns brought the most traffic to my site?
You want to know which of your campaigns draw in the most users.
SELECT install_source,
cnt1 ,
Concat(String(100*pct) , '%') AS percent_from_total
FROM (
SELECT install_source,
cnt1 ,
Ratio_to_report(cnt1) OVER () AS pct
FROM (
SELECT install_source,
Count(*) AS cnt1
FROM (
SELECT install_source,
customer_user_id
FROM accounts
GROUP BY install_source,
customer_user_id )
GROUP BY install_source
ORDER BY cnt1 DESC )
ORDER BY cnt1 DESC ) limit 5