select
case when to_char(STATUSTIME,'hh24:mi') BETWEEN '01:00' AND '01:59' then '1:00-2:00’
when to_char(STATUSTIME,'hh24:mi') BETWEEN '02:00' AND '02:59' then '2:00-3:00'
when to_char(STATUSTIME,'hh24:mi') BETWEEN '03:00' AND '03:59' then '3:00-4:00'
from dual
select
case when status_time = 2 then '1:00-2:00'
when status_time = 9 then '9:00-10:00'
else '3:00-4:00' end
from ( select to_char( c.create_time,'hh24') as status_time from table_name c)
不需要用between and 直接拿小时数比较就可以
STATUSTIME没有 , 而且 字符的比较是通过ascii码,这种直接比较单个的字符串是否相等 ,或者比较数值范围比较
@人间春风意: 我这个是字段STATUSTIME
@借口/*-: 我是说你查的是dual,不是实际的表,没有这个字段
@人间春风意: 好吧 我又犯傻了
@人间春风意: 谢谢您
@借口/*-: 不客气