在Teradata中选择时间间隔大于特定值的记录

时间:2017-07-18 08:27:54

标签: teradata sqldatetime

我遇到了一个简单的问题,就是找出哪些查询需要比平常更多的查询才能完成。我的脚本如下:

locking row for access
SELECT 
username, 
CollectTimeStamp, 
((firstresptime - starttime  ) HOUR TO second  ) AS ElapsedTime,
((firstresptime - firststeptime  ) HOUR  TO second ) AS ExecutionTime,
CAST(((firstresptime - firststeptime) SECOND) AS INTEGER) AS ExecutionTimeInt,
(ElapsedTime - ExecutionTime) AS Delay, 
-- other kpis here
FROM dbql_data.dbql_all
where username ='MyUser'; 
and dateofday> '2017-07-01'
    and ExecutionTimeInt > 5

但是,我得到ExecutionTimeInt小于5的记录。

问题:如何获取时间间隔大于某个值的记录?

额外信息:

select * from dbc.dbcinfo;返回

    InfoKey InfoData
1   VERSION 15.10.04.10
2   RELEASE 15.10.04.02
3   LANGUAGE SUPPORT MODE   Standard

1 个答案:

答案 0 :(得分:3)

ExecutionTimeInt计算可能会因Interval overflow而失败,因为其限制为9999秒。

ElapsedTime是一个间隔,比较的正确方法是:

WHERE ElapsedTime > interval '5' second

WHERE ElapsedTime > interval '1' minute