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

Grupo Mysql por día de la semana, complete los días de la semana que faltan

El enfoque normal es una left join :

select wd.wd, count(t.id)
from (select 1 as wd union all select 2 union all select 3 union all select 4 uion all
      select 5 union all select 6 union all select 7
     ) wd left join
     test t
     on wd.wd = weekday(t.date)
group by wd.wd
order by wd.wd;