简体   繁体   English

Oracle sql 查询查找最近 15 分钟的数据

[英]Oracle sql query to find the data as of last 15 minutes

I have a query that picks up the last_update_date in the format -我有一个查询以格式获取 last_update_date -

  person_number    last_update_date                                  location
     10             2021-06-10T16:02:50.222+00:00                     Peru
     11             2021-06-10T16:03:50.222+00:00                     Argentine

query-询问-

select person_number,
last_update_Date,
location

I want to add a where clause in this so that the query picks up only the last 15 minutes chanegs in the last_update_date.我想在其中添加一个 where 子句,以便查询仅获取 last_update_date 中的最后 15 分钟更改。 ie all teh records that has the timestamp for last 15 minutes.即所有具有过去 15 分钟时间戳的记录。

is there a way to do this ?有没有办法做到这一点 ?

Check if date column is between sysdate(this is current time) and sysdate- (1/1440*15)(this is current time -15 minutes)检查日期列是否在 sysdate(这是当前时间)和 sysdate-(1/1440*15)(这是当前时间 -15 分钟)之间

select person_number,
last_update_Date,
location,
sysdate,
sysdate - (1/1440*15) 
from tab1
where last_update_date between sysdate - (1/1440*15) and sysdate  

Here is a demo made at 2022-06-10 20:35:00 这是在 2022-06-10 20:35:00 制作的演示

Use an INTERVAL :使用INTERVAL

SELECT person_number,
       last_update_Date,
       location
FROM   table_name
WHERE  last_update_date BETWEEN SYSDATE - INTERVAL '15' MINUTE
                            AND SYSDATE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM