Java知识分享网 - 轻松学习从此开始!    

Java知识分享网

Java1234官方群25:java1234官方群17
Java1234官方群25:838462530
        
SpringBoot+SpringSecurity+Vue+ElementPlus权限系统实战课程 震撼发布        

最新Java全栈就业实战课程(免费)

springcloud分布式电商秒杀实战课程

IDEA永久激活

66套java实战课程无套路领取

锋哥开始收Java学员啦!

Python学习路线图

锋哥开始收Java学员啦!

Oracle时间区间段合并 PDF 下载


分享到:
时间:2021-09-18 09:17来源:http://www.java1234.com 作者:转载  侵权举报
Oracle时间区间段合并 PDF 下载
失效链接处理
Oracle时间区间段合并 PDF 下载


本站整理下载:
提取码:nnar 
 
 
相关截图:
 
主要内容:

实现的SQL如下: SELECT ID, SUM (C) FROM (SELECT ID, RN, (MAX (END_TIM) ­ MIN (BEG_TIM)) * 24 C FROM (SELECT ID, BEG_TIM, END_TIM, SUM (F) OVER (PARTITION BY ID ORDER BY BEG_TIM) AS RN FROM (SELECT T.* , CASE WHEN MAX (END_TIM) OVER (PARTITION BY ID O RDER BY BEG_TIM ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) >= BEG_TIM THE N 0 ELSE 1 END AS F FROM TAB_0 T)) GROUP BY ID, RN) GROUP BY ID 数据如下: WITH TAB_0 AS (SELECT 1 ROWID_, 1 ID, TO_DATE ('20200103 060000', 'YYYYMMDD HH24MISS') BEG_TIM, TO_DATE ('20200103 080000', 'YYYYMMDD HH24MISS') END_TIM, 'admin ' OPER FROM DUAL UNION ALL SELECT 2 ROWID_, 1 ID, TO_DATE ('20200103 050000', 'YYYYMMDD HH24MISS') BEG_TIM, TO_DATE ('20200103 063000', 'YYYYMMDD HH24MISS') END_TIM, 'admin ' OPER FROM DUAL UNION ALL SELECT 3 ROWID_, 1 ID, TO_DATE ('20200103 100000', 'YYYYMMDD HH24MISS') BEG_TIM, TO_DATE ('20200103 150000', 'YYYYMMDD HH24MISS') END_TIM, 'admin ' OPER FROM DUAL UNION ALL SELECT 4 ROWID_, 1 ID, TO_DATE ('20200103 140000', 'YYYYMMDD HH24MISS') BEG_TIM, TO_DATE ('20200103 160000', 'YYYYMMDD HH24MISS') END_TIM, 'admin ' OPER FROM DUAL UNION ALL SELECT 4 ROWID_, 1 ID, TO_DATE ('20200103 180000', 'YYYYMMDD HH24MISS') BEG_TIM, TO_DATE ('20200103 200000', 'YYYYMMDD HH24MISS') END_TIM, 'admin ' OPER
FROM DUAL UNION ALL SELECT 5 ROWID_, 1 ID, TO_DATE ('20200103 170000', 'YYYYMMDD HH24MISS') BEG_TIM, TO_DATE ('20200103 190000', 'YYYYMMDD HH24MISS') END_TIM, 'admin ' OPER FROM DUAL UNION ALL SELECT 6 ROWID_, 1 ID, TO_DATE ('20200103 070000', 'YYYYMMDD HH24MISS') BEG_TIM, TO_DATE ('20200103 100000', 'YYYYMMDD HH24MISS') END_TIM, 'admin ' OPER FROM DUAL) SELECT * FROM TAB_0 ORDER BY BEG_TIM ASC

 

------分隔线----------------------------

锋哥公众号


锋哥微信


关注公众号
【Java资料站】
回复 666
获取 
66套java
从菜鸡到大神
项目实战课程

锋哥推荐