4. 通过与T100做笛卡尔积枚举30天的所有日期
select min_hd + (t500.id -1) as 日期
from (select min(hiredate) as min_hd , Max(hiredate) as max_hd
from emp
where ename in ('blake','jones')
) x ,t500
where t.500.id <=((max_hd-min_hd)+1)
结果为
日期
1981-04-02
1981-04-03
1981-04-04
1981-04-05
1981-04-06
...
1981-05-01
5.根据日期得到对应的工作日消息
select 日期 to_char(日期 ,'DY','NLS_date_language= American') as dy
from (select min (hiredate) a+(t500.id -1) as 日期
from (select min (hiredate)as min_hd , Max(hiredate) as max_hd
from emp
where ename in ('blake','jones')) x,t500
where t500.id< ((nax_hd-min_hd)+1));
结果为
日期 dy
1981-04-02 thu
1981-04-03 fri
1981-04-04 sat
1981-04-05 sun
1981-04-06 mon
...
1981-05-01 fri
6.进行过滤工作工作天数汇总
selectcount(*)
from(
select 日期 to_char(日期 ,'DY','NLS_date_language= American') as d
Oracle查询优化改写——抄书学习04
最新推荐文章于 2020-12-07 22:48:28 发布
本文介绍了Oracle数据库中关于日期的操作,包括使用SYSDATE获取当前日期信息,通过TRUNC函数获取月初日期,以及如何利用TO_CHAR和TO_NUMBER转换日期的各个部分,如小时、分钟、秒、日、月和年。
摘要由CSDN通过智能技术生成