如何在配置单元表中获取最近3个月的数据

flmtquvp  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(144)

我正在使用下面的命令从配置单元获取过去3个月的数据。
从xyz中选择*在“2017-01-06 00:00:00”和“2017-03-06 23:59:59”之间创建;
如何在配置单元中获取最近3个月的数据而不使用between关键字。

enxuqcxy

enxuqcxy1#

如果你的专栏 creat_ts 类型 timestamp 你可以这样写你的查询

select * from xyz where from_unixtime(creat_ts) > '2017-01-05' and from_unixtime(creat_ts) < '2017-03-07';

或者如果列的类型为 datetime 或者 date 那么你的问题就是

select * from xyz where creat_ts > '2017-01-05' and creat_ts < '2017-03-07';

希望这会有帮助

相关问题