【发布时间】:2015-09-26 10:40:46
【问题描述】:
我有这样看起来记录的餐桌预订:
id | from | to
------+---------------------+---------------------
101 | 2015-09-24 08:00:00 | 2015-09-24 09:30:00
2261 | 2015-09-24 09:00:00 | 2015-09-24 10:00:00
4061 | 2015-09-24 10:00:00 | 2015-09-24 10:30:00
204 | 2015-09-24 12:00:00 | 2015-09-24 13:30:00
2400 | 2015-09-24 13:30:00 | 2015-09-24 14:00:00
4224 | 2015-09-24 14:00:00 | 2015-09-24 14:30:00
309 | 2015-09-24 16:00:00 | 2015-09-24 17:30:00
2541 | 2015-09-24 17:00:00 | 2015-09-24 18:00:00
我正在寻找最佳查询来找到问题的答案:
Is this possible to find a timeslot with duration x (ie. 30 minutes) in above records?
我有使用 postgres 数组或时间范围的想法,但仍在寻找更好的想法......
编辑:我将提供“假”预订作为界限,但如果您有更好的方法,请写信:)
【问题讨论】:
-
这个问题似乎不完整。如果您没有预订,那么您不能对时间段进行细化。换句话说,您需要提供开始和结束信息。
-
@GordonLinoff :你是对的。我目前假设 [ -infinity,+infinity ]
-
我编辑了问题,谢谢通知!
标签: sql database postgresql gaps-in-data