[Solved] SELECT COUNT(DISTINCT column) doesn’t work


The distinct keyword is supposed to be outside like below,

SELECT DISTINCT column1, column2, ...
FROM table_name; 
?

Also, you are trying to sum few things, It should be something like below,

SELECT UID, COUNT(UID) AS TOTAL, 
     SUM(CASE WHEN SYSTEM = 'Android' THEN 1 ELSE 0 END) AS A,
     SUM(CASE WHEN SYSTEM = 'IOS' THEN 1 ELSE 0 END) AS I,
     SUM(CASE WHEN SYSTEM = 'Windows' THEN 1 ELSE 0 END) AS W FROM user_visits
    GROUP BY UID

with aggregate (group by)

solved SELECT COUNT(DISTINCT column) doesn’t work