公司每天要进行打卡上班,每个人每天也可以多次打卡,所有打卡信息会记录到表A 中,表A中有name, date, time 等字段。
a. 要统计今天迟到的人的名单,请写出相应的SQL。
b. 每月会统计迟到次数排行前十的人的名单,请写出相应的SQL。
分析得之主要分以下三个子问题
1.迟到前十名
select `name`,count(`name`) as `sum`
from A
where (time>'09:00:00' or time is null)
group by `name`
order by `sum` desc
limit 0,10;
2.本月内
select *
from A
where date(now()) >= &#