下面是代碼以顯示員工「傑克」後誰被僱傭的員工的細節被聘爲顯示員工「傑克」後誰被僱傭的員工的細節被聘爲
所有信息在一張表中。
我的查詢:
select e.employee_name, e.hiredate
from employees e
where e.employee_hiredate > jack.hiredate;
下面是代碼以顯示員工「傑克」後誰被僱傭的員工的細節被聘爲顯示員工「傑克」後誰被僱傭的員工的細節被聘爲
所有信息在一張表中。
我的查詢:
select e.employee_name, e.hiredate
from employees e
where e.employee_hiredate > jack.hiredate;
爲了讓您的 '千斤頂' 表中,你只需要一個連接:
select e.employee_name, e.hiredate
from employees e
join employees jack on jack.employee_name = 'Jack'
where e.employee_hiredate > jack.hiredate;
另外,您可以使用子查詢:
select e.employee_name, e.hiredate
from employees e
where e.employee_hiredate > (select hiredate from employees where employee_name = 'Jack');
This article可能會給你更好的解釋如何加入工作,並且this article會解釋一些關於s ubqueries。
Select *
from employees e
where convert(date,e.employee_hiredate) > (select convert(date,e.employee_hiredate)
from employees
where employee = 'jack'
)
由於您要選擇只與特定員工進行比較的記錄,因此您可以使用子查詢。
在甲骨文,你也許可以這樣做:
select e.employee_name, e.hiredate
from employees e
where TRUNC(e.employee_hiredate) > (SELECT TRUNC(HIREDATE) FROM EMPLOYEES WHERE EMPLOYEE_NAME = 'Jack');