【发布时间】:2015-04-15 18:45:54
【问题描述】:
我怎样才能允许 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 等
【问题讨论】:
-
Postgres 还是 MySQL?不能同时是两者。
-
我不知道 ZOHO 报告更喜欢什么,但 mysql 大部分时间都在工作。让我们试试Mysql
标签: mysql sql postgresql zoho fuzzy-comparison