我在MySQL中有两个表.在每个表中,保存了具有其MAC地址和状态区域信息的设备.
这些状态确实在某些时间戳记(startTime,endTime)及其持续时间(endTime-startTime)处开始和结束,并且是由某些ID引起的.
现在,我想找到某些事件“移动”和“负载”之间的重叠部分,这些重叠部分以天为单位,如下所示:
sum of time, when movement took place (value in the fiddle: 421)
sum of time, when load took place (value in the fiddle: 520)
sum of time, when movement and load took place (value in the fiddle: 391)
查询结果应如下所示:
ID DATE ALL_MOVEMENT ALL_LOAD LOAD_MOVEMENT
00:50:c2:63:10:1a October, 29 2012 00:00:00+0000 421 520 391
00:50:c2:63:10:1a February, 22 2013 00:00:00+0000 421 520 391
00:50:c2:63:10:1b February, 22 2013 00:00:00+0000 181 220 181
更新:在这里可以看到一个小提琴,它以不同的表结构提供了我想要的东西: