0

I want to get the sum of the data for every 5 minutes. I have 15 motes. for ,suppose in the first 5 minutes only some motes are queried and in the next 5 minutes other some motes are queried. Now,In the second 5 minutes I need the data of the motes which are not queried in that 5minutes also ie.,in the first 5minutes moteid's 1,2,3,4,9,12,14 are queried and in the second minutes moteid's 1,5,6,7,9,13,14 are queried. In the second 5 minutes,I need the data to be updated for the one's which are not queried also.Is it possible to get the data from the previous 5 minutes

moteid2 | 28 | 2012-09-25 17:45:43 | | 
moteid4 | 65 | 2012-09-25 17:45:49 | | 
moteid3 | 66 | 2012-09-25 17:45:51 | | 
moteid6 | 25 | 2012-09-25 17:45:56 | | 
moteid5 | 29 | 2012-09-25 17:45:58 | | 
moteid7 | 30 | 2012-09-25 17:46:05 | | 
moteid4 | 95 | 2012-09-25 17:50:29 | | 
moteid6 | 56 | 2012-09-25 17:50:35 | | 
moteid5 | 58 | 2012-09-25 17:50:36 | | 
moteid4 | 126 | 2012-09-25 17:55:08 |

In the first 5 minutes moteid2, moteid3 are queried, but after that in the next 5minutes they are not queried. Even If they are not being queried i want the same previous queried value to be kept now.

4

1 回答 1

1

我假设表名是motes. 在这种情况下,以下查询显示motesid整个表中存在但在过去 5 分钟内未查询的记录的所有唯一性:

select distinct m.motesid
from motes m
where not exists (
    select *
    from motes m1
    where 
        m1.moteid = m.motesid and
        m1.date > SUBTIME(CURTIME(), '0:05:00')
)
于 2012-09-25T15:12:51.657 回答