我有两个表要结合起来,以得出需要报告的数据。
要求是提取显示所有已聘用实习生的数据,并从这些实习生中提取数据,以计数我们聘用的所有实习生的全职职位。
问题是当我进行内部联接时,我只会得到被录用为全职职位的实习生,而不是所有被录用的实习生,无论他们是否过渡到了全职。
有什么建议吗?
答案 0 :(得分:0)
建议使用外部联接(而不是内部联接)。
这是一个示例:示例表:
select t.*
from (select t.*, sum(weight) over (order by id) as running_weight
from t
) t
where running_weight <= 200
order by id desc
fetch first 1 row only;
选择所有这些人,以区分被录用为全职职位的人:
SQL> create table t_first
2 (id number,
3 name varchar2(20));
Table created.
SQL> create table t_second
2 (id number,
3 name varchar2(20));
Table created.
SQL> insert into t_first (id, name)
2 select 1, 'Little' from dual union all
3 select 2, 'Foot' from dual union all
4 select 3, 'Scott' from dual union all
5 select 4, 'Tiger' from dual;
4 rows created.
SQL> insert into t_second (id, name)
2 select 3, 'Scott' from dual union all
3 select 4, 'Tiger' from dual;
2 rows created.
我不确定您“算”那些被录用为全职职位的人是什么意思。您想在哪里显示该信息?怎么样?如果您可以提供示例,则建议解决方案会更容易。