我有两个表employee(name,id),由所有员工和另一个表读者(id,date)组成,它提供日期和员工在场。如何在一定范围内找到缺席者列表约会?
对于特定日期,我可以使用命令:
SELECT DISTINCT employee.id,reader.dat FROM employee,reader
WHERE employee.id NOT IN (SELECT id FROM reader WHERE dat = '2011-01-18' )
AND reader.dat='2011-01-18';
答案 0 :(得分:0)
将BETWEEN
运算符与您想要的日期范围一起使用。
即,
select id
from reader
where date BETWEEN '2011-01-16' AND '2011-01-19'
group by id having count(*) < 4;