SQL:查找在一周的特定日期雇用的所有员工
SQL: Finding all employees hired on a specific day of the week
我很难找到在一周中的某一天(星期一、星期二等)雇用率最高的所有员工。
例如:如果星期一是雇用人数最多的一天,我想显示一周中这一天雇用的所有员工。
我发现哪些日子的招聘人数最多:
SELECT COUNT(*), TO_CHAR(HIRE_DATE,'DAY') DAY
FROM EMPLOYEES
GROUP BY TO_CHAR(HIRE_DATE,'DAY')
HAVING COUNT (*)=(SELECT MAX(COUNT(*))FROM EMPLOYEES GROUP BY TO_CHAR(HIRE_DATE,'DAY'));
但我无法显示当天雇用的所有员工。预先感谢您的宝贵时间。
我不懂 Oracle 语法,但在该查询中加入了 EMPLOYEES。类似于:
SELECT e.*
FROM EMPLOYEES e
INNER JOIN
(SELECT <employee id>, TO_CHAR(HIRE_DATE,'DAY') DAY
FROM EMPLOYEES
GROUP BY TO_CHAR(HIRE_DATE,'DAY')
HAVING COUNT (*)=(SELECT MAX(COUNT(*))FROM EMPLOYEES GROUP BY TO_CHAR(HIRE_DATE,'DAY'))) AS empdays
ON TO_CHAR(e.HIRE_DATE, 'DAY') = empdays.DAY;
怎么样:
select * from employees
where to_char(HIRE_DATE,'DAY') in
SELECT TO_CHAR(HIRE_DATE,'DAY') DAY
FROM EMPLOYEES
GROUP BY TO_CHAR(HIRE_DATE,'DAY')
HAVING COUNT (*)=(SELECT MAX(COUNT(*))FROM EMPLOYEES GROUP BY TO_CHAR(HIRE_DATE,'DAY'));
我很难找到在一周中的某一天(星期一、星期二等)雇用率最高的所有员工。
例如:如果星期一是雇用人数最多的一天,我想显示一周中这一天雇用的所有员工。
我发现哪些日子的招聘人数最多:
SELECT COUNT(*), TO_CHAR(HIRE_DATE,'DAY') DAY
FROM EMPLOYEES
GROUP BY TO_CHAR(HIRE_DATE,'DAY')
HAVING COUNT (*)=(SELECT MAX(COUNT(*))FROM EMPLOYEES GROUP BY TO_CHAR(HIRE_DATE,'DAY'));
但我无法显示当天雇用的所有员工。预先感谢您的宝贵时间。
我不懂 Oracle 语法,但在该查询中加入了 EMPLOYEES。类似于:
SELECT e.*
FROM EMPLOYEES e
INNER JOIN
(SELECT <employee id>, TO_CHAR(HIRE_DATE,'DAY') DAY
FROM EMPLOYEES
GROUP BY TO_CHAR(HIRE_DATE,'DAY')
HAVING COUNT (*)=(SELECT MAX(COUNT(*))FROM EMPLOYEES GROUP BY TO_CHAR(HIRE_DATE,'DAY'))) AS empdays
ON TO_CHAR(e.HIRE_DATE, 'DAY') = empdays.DAY;
怎么样:
select * from employees
where to_char(HIRE_DATE,'DAY') in
SELECT TO_CHAR(HIRE_DATE,'DAY') DAY
FROM EMPLOYEES
GROUP BY TO_CHAR(HIRE_DATE,'DAY')
HAVING COUNT (*)=(SELECT MAX(COUNT(*))FROM EMPLOYEES GROUP BY TO_CHAR(HIRE_DATE,'DAY'));