自学内容网 自学内容网

SQL进阶技巧:如何找出开会时间有重叠的会议室?| 时间区间重叠问题

目录

0 场景描述

1 数据准备

2 问题分析

方法1:利用 lateral view posexplode()函数将表展开成时间明细表

方法2:利用数学区间讨论思想求解

3 小结


0 场景描述

有7个会议室,每个会议室每天都有人开会,某一天的开会时间如下:

查询出开会时间有重叠的是哪几个会议室?上面预期结果是 ID 2 3 4 5 6 

1 数据准备

create table  meeting as(
select 1 id,'08:00' starttime,'09:15' endtime
union all
select 2,'13:20','15:20'
union all
select 3,'10:00','14:00'
union all
select 4,'13:55','16:25'
union all
select 5,'14:00','17:45'
union all
select 6,'14:05','17:45&#

原文地址:https://blog.csdn.net/godlovedaniel/article/details/142965705

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!