Oracle数据库sql查询。有?
显示在雇员人数最多的一周中的某一天雇用的所有雇员的姓名 表:Oracle数据库sql查询。有?,sql,database,oracle,Sql,Database,Oracle,显示在雇员人数最多的一周中的某一天雇用的所有雇员的姓名 表: Steven 06/17/1987 Neena 09/21/1989 Lex 01/13/1993 Alex 01/03/1990 Bruce 05/21/1991 Diana 02/07/1999 Kevin 11/16/1999 Trenna 10/17/1995 Curtis 01/29/1997 Randall 03/15/1998 Peter 07/09/1998 Eleni 01
Steven 06/17/1987
Neena 09/21/1989
Lex 01/13/1993
Alex 01/03/1990
Bruce 05/21/1991
Diana 02/07/1999
Kevin 11/16/1999
Trenna 10/17/1995
Curtis 01/29/1997
Randall 03/15/1998
Peter 07/09/1998
Eleni 01/29/2000
Ellen 05/11/1996
Jonath 03/24/1998
Kimber 05/24/1999
Jenni 09/17/1987
Michael 02/17/1996
Pat 08/17/1997
Shelley 06/07/1994
William 06/07/1994
到目前为止我所拥有的
SELECT FIRST_NAME, to_char(hire_date,'d') AS DOW FROM EMPLOYEES;
Steven 4
Neena 5
Lex 4
Alex 4
Bruce 3
Diana 1
Kevin 3
Trenna 3
Curtis 4
Randall 1
Peter 5
Eleni 7
Ellen 7
Jonath 3
Kimbe 2
Jenni 5
Michael 7
Pat 1
Shelley 3
William 3
星期天是1,星期一是2。。。等等
现在我需要选择一个最大重复次数的
看看桌子,我们就知道现在是3点(星期二)。我知道我需要使用子查询来获取它,它是否具有?单向,将您的查询扩展到上面():
一种方法是将查询扩展到()之上:
我倾向于对此使用分析函数:
select e.*
from (SELECT to_char(hire_date, 'd') AS DOW, count(*) as cnt,
row_number() over (order by count(*) desc) as seqnum
FROM EMPLOYEES
) dow join
EMPLOYEEs e
on dow.DOW = to_char(e.hire_date, 'd') and seqnum = 1;
我倾向于对此使用分析函数:
select e.*
from (SELECT to_char(hire_date, 'd') AS DOW, count(*) as cnt,
row_number() over (order by count(*) desc) as seqnum
FROM EMPLOYEES
) dow join
EMPLOYEEs e
on dow.DOW = to_char(e.hire_date, 'd') and seqnum = 1;
select *
from employees
where to_char(hire_date, 'd') = (
select max(to_char(hire_date, 'd')) keep (dense_rank last order by count(*))
from employees
group by to_char(hire_date, 'd')
);