欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

子查询 Oracle 

程序员文章站 2024-02-10 20:37:52
...

Show all employees who were hired on the day of the week on which the highest number of employees were hired.
---查询在星期几入职的员工最多并显示出有哪些员工?
---解释:判断条件在员工表中先找出在”哪一天“,哪一天的判断条件是在员工表中找出”入职人数最多“的那一天
SELECT last_name, TO_CHAR(hire_date, 'DAY') day
  FROM employees
WHERE TO_CHAR(hire_date, 'DAY') =
       (SELECT TO_CHAR(hire_date, '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