Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Wählen Sie mit zwei Zählungen in derselben Spalte

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