【发布时间】:2023-01-08 13:28:19
【问题描述】:
我有两个表 emp 和类型。
create table EMP(ID number(10), effective_date date);
EID Effective_date
--------------------
1 02/14/2023
2 02/15/2023
3 04/30/2023
4 03/24/2023
create table type(ID number(10),contract_type varchar2(2));
TID contract_type
------------------
1 P
1 S
1 P
2 S
2 S
3 P
3 S
4 S
我正在查看合同类型在类型表中为“S”的 EID。 (或者生效日期的emp表大于sysdate并且类型表中只有contract_type ='S')
实际结果 :
2个
4个
我的查询没有给出正确的结果。
select emp.EID
from emp,type
where EID = TID
contract_type ='S'
effective_date >= sysdate
group by TID
having count(TID) >= 1;
【问题讨论】:
-
请在您的问题中将预期结果添加为表格。