Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Selecione com duas contagens na mesma coluna

SELECT MONTH(date) AS month, 
       count(DISTINCT case when field = 1 then ip end) as f1,
       count(DISTINCT case when field = 2 then ip end) as f2
FROM table_name 
WHERE field in (1,2)
GROUP BY month