问题描述
我在 hive 中有一个带有列的登录详细信息表
I have a login details table in hive with columns
(日期、时间、用户)
我正在尝试编写一个查询,该查询可以选择在两个日期之间登录的用户,同时还要考虑时间.例如:我想知道在 10-12-2012
02:30:00
和 28-12-2012
之间登录的用户> 16:20:00
.DD-MM-YYYY
格式的日期和 HH:MM:SS
格式的时间.
I am trying to write a query which can select users who have logged in between two dates with time also taking in consideration. For example: I want to know the users who have logged in between 10-12-2012
02:30:00
and 28-12-2012
16:20:00
. Dates in DD-MM-YYYY
and Time in HH:MM:SS
format.
我可以执行
select * from test_table where time between "02:30:00" and "16:20:00" ;
select * from test_table where date between "10-12-2012" and "28-12-2012" ;
但是我不知道如何在获取所需结果时同时考虑日期和时间列.请指导我.提前致谢
But i am not getting how to take both date and time columns into consideration while fetching the required result. Please guide me. Thanks in advance
推荐答案
SELECT * FROM test_table
WHERE date BETWEEN "11-12-2012" AND "27-12-2012"
OR (date = '10-12-2012' and time >= '02:30:00')
OR (date = '28-12-2012' and time <= '16:20:00');
这篇关于合并配置单元中的两列并在运算符之间使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!