HOW TO SELECT row as COUNT() or how to count rows

Post Reply
User avatar
sonik
Site Admin
Posts: 35
Joined: 12 Nov 2018, 22:12

HOW TO SELECT row as COUNT() or how to count rows

Post by sonik » 13 Nov 2018, 10:56

SELECT browser, COUNT(browser) AS freq FROM

Code: Select all

SELECT browser, COUNT(browser) AS freq FROM
(SELECT
CASE
WHEN useragent LIKE '%Chrome%' THEN 'Chrome'
WHEN useragent LIKE '%Safari%' THEN 'Safari'
WHEN useragent LIKE '%Firefox%' THEN 'Firefox'
WHEN useragent LIKE '%MSIE 7%' THEN 'IE7'
WHEN useragent LIKE '%MSIE 8%' THEN 'IE8'
WHEN useragent LIKE '%MSIE 9%' THEN 'IE9'
WHEN useragent LIKE '%MSIE 10%' THEN 'IE10'
WHEN useragent LIKE '%rv:11%' THEN 'IE11'
ELSE 'Other'
END browser
FROM loginhistory) AS browsers
GROUP BY browser
ORDER BY freq DESC

Post Reply