0

我正在尝试恢复距当前时间超过 5 分钟的记录。这是我到目前为止所拥有的,但它似乎带回了所有记录,而不仅仅是超过 5 分钟的记录:

SELECT COUNT(DISTINCT "DOCUMENT_QUEUE"."DOCUMENT_NUMBER") as "Records" 
FROM   "MAGINUS"."DOCUMENT_QUEUE" "DOCUMENT_QUEUE"
WHERE  to_date('01-JAN-1970', 'dd-MON-yyyy HH:MI:SS') + (DOCUMENT_QUEUE.CREATION_DATE/86400) > sysdate - 38/1440
ORDER BY "DOCUMENT_QUEUE"."DOCUMENT_NUMBER"
4

3 回答 3

7

使用区间文字

SELECT COUNT(DISTINCT "DOCUMENT_QUEUE"."DOCUMENT_NUMBER") as "Records" 
FROM   "MAGINUS"."DOCUMENT_QUEUE" "DOCUMENT_QUEUE"
WHERE  DOCUMENT_QUEUE.CREATION_DATE < SYSDATE - INTERVAL '5' MINUTE
ORDER BY "DOCUMENT_QUEUE"."DOCUMENT_NUMBER";
于 2013-06-04T19:17:27.820 回答
2

这应该有效:

SELECT COUNT(DISTINCT "DOCUMENT_QUEUE"."DOCUMENT_NUMBER") as "Records" 
FROM   "MAGINUS"."DOCUMENT_QUEUE" "DOCUMENT_QUEUE"
WHERE  round(to_number(DOCUMENT_QUEUE.CREATION_DATE-sysdate)*1440) > 15
ORDER BY "DOCUMENT_QUEUE"."DOCUMENT_NUMBER"
于 2013-06-04T15:47:14.487 回答
-1

使用NOW()(date_to_unix_ts(DOCUMENT_QUEUE.CREATION_DATE) - 86400 )来定义范围。

于 2013-06-04T15:41:15.727 回答