sql >> Base de Datos >  >> RDS >> Mysql

Seleccionar con dos conteos en la misma columna

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