求教这个句子该怎么写

瞌觉兴国 2015-03-17 10:02:49
select x.url,
(select z.url_description
from zzd_sys_url_list z
where x.url = z.url_list) 功能说明,
count(x.url) 点击次数
from SYS_RUNTIME_REQ_REC_ARCHIVE X
where to_char(x.enter_time, 'yyyy-mm-dd ') between '2015-03-09' and
'2015-03-13'
and to_char(x.exit_time, 'hh24-mi-ss ') - to_char (x.enter_time,'hh24-mi-ss') > '00-00-03'
group by x.url
order by 点击次数 desc;

这是查系统内一些功能在某个时间段的点击次数。 红色部分是想 统计 超过3S的功能
加上这个执行老是报无效数字
求教是怎么回事
...全文
169 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
IceIsabel 2015-03-19
  • 打赏
  • 举报
回复
引用 5 楼 z2313531 的回复:
[quote=引用 2 楼 IceIsabel 的回复:] to_char(x.enter_time, 'yyyy-mm-dd ') between '2015-03-09' and '2015-03-13' 这里最好不要这样写,改为:x.enter_time between to_date('2015-03-09' ,'yyyy-mm-dd') and to_date( '2015-03-13 23:59:59' ,'yyyy-mm-dd hh24:mi:ss')
为什么?[/quote] 就像4楼说的,若enter_time有索引的话,加上to_char将不会用到索引
瞌觉兴国 2015-03-19
  • 打赏
  • 举报
回复
引用 1 楼 wenyzh 的回复:
and x.exit_time - x.enter_time > 3/60/60/24
试了一下,查出来了,谢谢
瞌觉兴国 2015-03-19
  • 打赏
  • 举报
回复
引用 4 楼 z_shousi 的回复:
where to_char(x.enter_time, 'yyyy-mm-dd ') between '2015-03-09' and '2015-03-13' and to_char(x.exit_time, 'hh24-mi-ss ') - to_char (x.enter_time,'hh24-mi-ss') > '00-00-03' 可调整为

 WHERE x.enter_time BETWEEN to_date('2015-03-09','YYYY-MM-DD') AND to_date('2015-03-13','YYYY-MM-DD')
    --此处最好在后面参数to_date,若你enter_time有索引的话,你to_char字段将不会用到索引
   AND x.exit_time- x.enter_time > 3/24/60/60
   --此处3/24(小时)/60(分钟)/60(秒)  代表3秒
谢谢
瞌觉兴国 2015-03-19
  • 打赏
  • 举报
回复
引用 2 楼 IceIsabel 的回复:
to_char(x.enter_time, 'yyyy-mm-dd ') between '2015-03-09' and '2015-03-13' 这里最好不要这样写,改为:x.enter_time between to_date('2015-03-09' ,'yyyy-mm-dd') and to_date( '2015-03-13 23:59:59' ,'yyyy-mm-dd hh24:mi:ss')
为什么?
IceIsabel 2015-03-17
  • 打赏
  • 举报
回复
to_char(x.enter_time, 'yyyy-mm-dd ') between '2015-03-09' and '2015-03-13' 这里最好不要这样写,改为:x.enter_time between to_date('2015-03-09' ,'yyyy-mm-dd') and to_date( '2015-03-13 23:59:59' ,'yyyy-mm-dd hh24:mi:ss')
  • 打赏
  • 举报
回复
and x.exit_time - x.enter_time > 3/60/60/24
  • 打赏
  • 举报
回复
where to_char(x.enter_time, 'yyyy-mm-dd ') between '2015-03-09' and '2015-03-13' and to_char(x.exit_time, 'hh24-mi-ss ') - to_char (x.enter_time,'hh24-mi-ss') > '00-00-03' 可调整为

 WHERE x.enter_time BETWEEN to_date('2015-03-09','YYYY-MM-DD') AND to_date('2015-03-13','YYYY-MM-DD')
    --此处最好在后面参数to_date,若你enter_time有索引的话,你to_char字段将不会用到索引
   AND x.exit_time- x.enter_time > 3/24/60/60
   --此处3/24(小时)/60(分钟)/60(秒)  代表3秒
无敌小二傻 2015-03-17
  • 打赏
  • 举报
回复
直接写就可以了!!! (x.exit_time-x.enter_time)*24*60*60>3

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧