我的数据格式是
machine_id,channel_id, start_time, end_time
31415926,100,20160201142334,20160201145832
31415926,103,20160201145839,20160201165832
31415926,108,20160201172334,20160201195832
31415928,103,20160201012334,20160201145832
31415928,100,20160201172334,20160201225832
31415928,108,20160201232334,20160201235832
都是String类型。
那么现在要写hql语句去查 表中 从20160201140000 到 20160201160000 观看了 103 的机器有多少个,
select count(distinct machine_id) from table_name where ( (20160201140000 < cast(start_time as int)) And (cast(start_time as int)< 20160201160000) ) OR ((20160201140000 < cast(end_time as int)) And (cast(end_time as int)<20160201160000));
悍然报错,NoViableAltException(292@[])
FAILED: ParseException line 1:30 cannot recognize input near 'where' '(' '(' in join source
我在网上找的 hql 得数据类型转换,从String 类型转到 int 类型是这样转吧? cast(string as int)
那么我这个hql语句写错了没呢? 有没有关于hql 语句这方面的资料可以推荐的呢?
多谢!
|
|