我正在处理两个SQL查询。查询1提取员工每天在办公室工作超过8小时的数据,因此看起来像:
select a.empname, a.empid
from emp a
join shift b on a.dept=b.dept
where empid is not null
and a.month= '1'
group by a.empname, a.empid
having count (shifthours)>8
intersect
select a.empname, a.empid
from emp a
join shift b on `a.dept` = `b.dept`
where empid is not null
and a.month='2'
group by `a.empname, a.empid`
having count (`shifthours`)>9
当我运行此查询时,它不会提取正确的结果。如果我单独运行两个查询并在Excel中使用VLOOKUP,它会给我正确的结果。