Det normala tillvägagångssättet är en 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;