1

我有一个像这样的表结构,其中定义了员工与经理的关系

EMP_ID SUP_ID START_DATE END_DATE
emp1 sup1 2012 年 1 月 1 日 2012 年 1 月 30 日
emp1 sup2 2012 年 2 月 1 日 2012 年 2 月 28 日
emp2 sup1 2012 年 1 月 1 日 2012 年 2 月 28 日

我需要查询以获取截至 sysdate 的经理下的所有员工。

即,如果我在 1 月使用 mgr id sup1 执行它,它应该返回 emp1 和 emp2
,如果它在 2 月它应该只返回 emp2。

我尝试使用连接编写查询,但它不起作用,我对在哪里放置什么条件感到困惑。

4

2 回答 2

1

下面肯定可以工作吗?

select * from employees
where sysdate between start_date and end_date
and sup_id = 'sup1';
于 2012-08-28T11:10:06.973 回答
0
select * from employees where sup_id = 'sup1' and start_date = trunc(sysdate);
于 2013-01-05T16:59:58.997 回答