我怎样才能允许 1 - 10 秒的容差?
我有 2 个带有时间戳的表,但延迟了 1-10 秒。我正在使用内部连接来比较它们。我在两个表中都有电话号码(列)匹配但不能使它们与时间戳匹配(仅限时间)。为了允许一定的容忍度,我可以使用类似的表达式cast(DateCreated as Time) = cast(TIMESTAMP as time) + 5
。但我不想每一秒都这样做。
SELECT Time_To_Sec(cast("table1_DateCreated" as time)) as DateCreated
, Time_To_Sec(cast("table2"."Timestamp" as time)) as Timestampe
, "Direction","FromTW", "ToTW", "table2"."ANI","table2"."CALL ID"
, "table2"."Disposition"
FROM "calls and time"
INNER JOIN "table2" on cast(DateCreated as Time)=cast(TIMESTAMP as time)+5
and FromTW="table2"."ANI"
如果可能的话,我希望看到以下结果:
table1(DateCreated) | table2(Timestamp) | compared results
---------------------+---------------------+-----------------
5000 | 5005 | table3
5001 | 5009 | table3
5001 | 5050 | not in table3
如果满足条件,则将其发送到表 3,但如果不满足条件,则不会将其发送到表 3。
使用 Zoho 报告,因此我不确定他们使用的是什么类型的数据库。Postgres、MySQL 等