Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hive 如何在蜂巢中到达_epoch(sysdate-90)_Hive_Hiveql_Unix Timestamp_Sysdate - Fatal编程技术网

Hive 如何在蜂巢中到达_epoch(sysdate-90)

Hive 如何在蜂巢中到达_epoch(sysdate-90),hive,hiveql,unix-timestamp,sysdate,Hive,Hiveql,Unix Timestamp,Sysdate,我有一个在Oracle中运行良好的查询,但我想在配置单元中使用相同的查询 查询: select count(mem_id) from mem where cobrand_id = '10001372' and user_type_id =1 and status_ind <>3 and LAST_ACCESSED >= to_epoch(sysdate-90); 不走运。有人能帮我吗。提前感谢。似乎1.554386487E9是相同的unix历元时间,以双精度存储

我有一个在Oracle中运行良好的查询,但我想在配置单元中使用相同的查询

查询:

select count(mem_id)  
from mem 
where cobrand_id = '10001372' 
and user_type_id =1  
and status_ind <>3 
and LAST_ACCESSED >= to_epoch(sysdate-90);

不走运。有人能帮我吗。提前感谢。

似乎1.554386487E9是相同的unix历元时间,以双精度存储,以工程符号显示,并且可以转换为BIGINT

检查您的示例:

select from_unixtime(cast(1.554386487E9 as bigint));
OK
2019-04-04 07:01:27
这个时间戳好看吗

如果是,则使用
unix\u时间戳(concat(date\u sub(当前日期,90),'00:00:00'))
获取当前日期的纪元时间-90天

您的查询已修复:

select count(mem_id)  
from mem 
where cobrand_id = '10001372' 
and user_type_id =1  
and status_ind <>3 
and cast(LAST_ACCESSED as BIGINT) >=  unix_timestamp(concat(date_sub(current_date,90),' 00:00:00'))
选择计数(内存id)
来自mem
其中cobrand_id='10001372'
和用户类型id=1
和状态索引3
and cast(最后一次作为BIGINT访问)>=unix\u时间戳(concat(date\u sub(当前日期,90),'00:00:00'))

谢谢@leftjoin的回答。我试过下面的方法。来自unixtime(unix_timestamp()-90*60*60*24,'yyyyMMdd');但我在90天和180天内得到了相同的结果,甚至没有任何一天。我已经用你的回答代替了我的疑问,再次感谢。
select count(mem_id)  
from mem 
where cobrand_id = '10001372' 
and user_type_id =1  
and status_ind <>3 
and cast(LAST_ACCESSED as BIGINT) >=  unix_timestamp(concat(date_sub(current_date,90),' 00:00:00'))