作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个简单的表,其中包含节点、消息、开始时间、结束时间 详细信息,其中开始时间和结束时间采用 unix 时间戳。我正在运行的查询是:
select node, message, (select from_unixtime(starttime)), (select from_unixtime(endtime)) from table1 WHERE try(select from_unixtime(starttime)) > to_iso8601(current_timestamp - interval '24' hour) limit 100
查询无效并抛出语法错误。
我正在尝试从表中获取以下信息:
使用过去“n”小时或“n”天的开始时间和结束时间查询表,并以人类可读格式获取开始时间和结束时间的输出
使用人类可读格式的特定日期和时间查询表格
最佳答案
您不需要“额外”选择,也不需要 where 子句中的 to_iso8601
:
WITH dataset AS (
SELECT * FROM (VALUES
(1627409073, 1627409074),
(1627225824, 1627225826)
) AS t (starttime, endtime))
SELECT from_unixtime(starttime), from_unixtime(endtime)
FROM
dataset
WHERE from_unixtime(starttime) > (current_timestamp - interval '24' hour) limit 100
输出:
关于amazon-web-services - 如何在aws athena中查询unix epoch timestamp中的时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68546217/
我是一名优秀的程序员,十分优秀!