我需要在两个时间范围内提取数据,基本上我想提取早上交易的整个数据。
Column_A
2017-06-01 12:23:19
数据类型 - 字符串
我尝试了下面的查询,但它没有用。
use retail_apac;
select *
from bills
where concat(hour(Column_A),':',minute(Column_A),':',second(Column_A)) between '05:00:00' and '12:00:00';
答案 0 :(得分:1)
试试这个:
select *
from bills
where substr(Column_A , 12) between '05:00:00' and '12:00:00';
或
select *
from bills
where (hour(Column_A) between 5 and 11) OR (HOUR(Column_A)=12 and MIN(Column_A)=0 AND second(Column_A) = 0) ;
或(更放松)
select *
from bills
where hour(Column_A) between 5 and 11;