我有一个这样的表结构,其中定义了员工与经理的关系
EMP_ID SUP_ID START_DATE END_DATE emp1 sup1 01-JAN-2012 30-JAN-2012 emp1 sup2 01-FEB-2012 28-FEB-2012 emp2 sup1 01-JAN-2012 28-FEB-2012
我需要一个查询来从sysdate的管理员那里获得所有员工。
即如果我在jan上用mgr id sup1执行它,它应该返回emp1和emp2
如果是在feb上它应该只返回emp2。
我尝试使用连接编写查询,但它无法正常工作,我对如何放置条件感到困惑。
答案 0 :(得分:1)
下面肯定会有效吗?
select * from employees
where sysdate between start_date and end_date
and sup_id = 'sup1';
答案 1 :(得分:0)
select * from employees where sup_id = 'sup1' and start_date = trunc(sysdate);