如何找到入职不到十年的员工?
我想编写一个查询来显示所有工作时间少于 10 年的员工的员工编号、姓氏、雇用日期和受雇月数。
这是我所拥有的,但 WHERE 函数有问题:
SELECT employee_id, last_name, hire_date, MONTHS_BETWEEN(SYSDATE, hire_date) "number of months employed"
FROM employees
WHERE MONTHS_BETWEEN(SYSDATE, hire_date) <= 120;
PS:当我在没有 WHERE 函数的情况下运行它时,对于“雇用月数”,我得到 292.530207959976105137395459976105137395
请帮忙! :(
I want to write a query to display the employee number, last name, hire date, and number of months employed for all employees who have worked for less than 10 years.
This is what I have but something is wrong with the WHERE function:
SELECT employee_id, last_name, hire_date, MONTHS_BETWEEN(SYSDATE, hire_date) "number of months employed"
FROM employees
WHERE MONTHS_BETWEEN(SYSDATE, hire_date) <= 120;
PS: when I run it without the WHERE function, for the "number of months employed" I get 292.530207959976105137395459976105137395
please help! :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这意味着该公司在过去十年中没有雇用任何员工。
您使用的表基于规范的 SCOTT.EMP 表,该表中的所有员工都是在 20 世纪 80 年代的某个时间点聘用的。
您需要修改您的数据。尝试类似这样的查询。对于 ID 以奇数结尾的任何员工,它的雇用率将减少约 25 年:
This means the company hasn't hired any employees in the last ten years.
You are using a table based on the cannonical SCOTT.EMP table, where all the employees were hired at some point in the 1980s.
You'll need to amend your data. Try something like this query. It will lop approx twenty five years off the hiredate of any employee who ID ends in an odd digit: