select sum(1) as `人数`, DATE_FORMAT(`time`, '%Y') as `年份`, 1 as istotal from viewers group by DATE_FORMAT(`time`, '%Y')
union all
select sum(1), DATE_FORMAT(`time`, '%Y-%m-%d'), 0 from viewers group by DATE_FORMAT(`time`, '%Y-%m-%d');
istotal 如果是1, 则显示的是某次活动全部的签到人数。
istotal如果是0, 则显示的是活动中每天累计的签到人数。