获取一定间隔的数据?

5vf7fwbs  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(362)

我有一个表,我想使用一些查询获取特定行的属性time。

select  view,time from new_table where type="someType";

现在,对于上述查询结果中的每个时间项,我都要从另一个表中获取记录,该表在这个时间之前的最后1分钟出现过。

Result of query
 view1,14:06:45
 view2,14:07:45
 view3,14:08:45
 view4,14:09:45

fetchDataTable should give this output for the data view1,14:06:45

some1,Touchl,1151,547,2020/6/25, 14:05:45,
some2,TouchFl,1151,547,2020/6/25,14:06:14,
some3,TouchFl,1151,547,2020/6/25,14:06:20,
some4,TouchFl,1151,547,2020/6/25,14:06:24,

我想把表中的条目取出来 fetchDataTable 从那时起 14:05:45 to 14:06:45 . 表fetchdatatable也有属性time。我想对查询结果的每个条目都这样做!!

e0bqpujr

e0bqpujr1#

正式地:

SELECT t1.time, t2.*
FROM t1
JOIN t2 ON t2.time BETWEEN t1.time - INTERVAL 1 MINUTE AND t1.time
WHERE t1.type = 'someType'

SELECT t1.type, t1.time, t2.*
FROM t1
JOIN t2 ON t2.time BETWEEN t1.time - INTERVAL 1 MINUTE AND t1.time

(任务不够明确)

相关问题