假设你的原表叫eat,我新建一张表叫eat_pay,字段是 (用餐时段 姓名 用餐次数) create table eat_pay as select '06:00-10:29' as 早餐时间,t.name as 员工姓名,count(name) as 用餐次数 from eat t where to_char(time,'HH24:MI')'06:00' and to_char(time,'HH24:MI') '10:29' group by name
insert into eat_pay select '10:30-14:59' as 中餐时间,t.name as 员工姓名,count(name) as 用餐次数 from eat t where to_char(time,'HH24:MI')'10:30' and to_char(time,'HH24:MI') '14:59' group by name
insert into eat_pay select '15:00-20:59' as 晚餐时间,t.name as 员工姓名,count(name) as 用餐次数 from eat t where to_char(time,'HH24:MI')'15:00' and to_char(time,'HH24:MI') '20:59' group by name
insert into eat_pay select '21:00-23:29' as 宵夜时间,t.name as 员工姓名,count(name) as 用餐次数 from eat t where to_char(time,'HH24:MI')'21:00' and to_char(time,'HH24:MI') '23:29' group by name