Mysql
 sql >> Database >  >> RDS >> Mysql

Seleziona con due conteggi sulla stessa colonna

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