也就是说,0-2,2-4,……,22-24
请帮帮忙,谢谢

解决方案 »

  1.   

    count(case when 字段<='' and 字段>='' then 1 else null end)
      

  2.   

    看不明白楼上的呢,sql 我仅会简单的,呵呵
    我的是这样写的,select count(*) from case_info where to_date(to_char('"+txtStartDate+"','yyyy-MM-dd HH24:mi'),'hh24mi') >='0000'  and  to_date(to_char('"+txtEndDate+','yyyy-MM-dd HH24:mi'),'hh24mi')<='0020' txtStartDate="2007-01-01 00:00:00"
    txtEndDate="2007-05-51 00:00:00"这是统计凌晨0-2点,这样不行,请大家帮忙看看改怎么写、
      

  3.   

    select count(case when 
      to_date(to_char('"+txtStartDate+"','yyyy-MM-dd HH24:mi'),'hh24mi') >='0000'  
      and  to_date(to_char('"+txtEndDate+','yyyy-MM-dd HH24:mi'),'hh24mi')<='0020' 
                then 1
                else null end )
    from table
      

  4.   

    select count(case when to_date(to_char('2007-04-01 00:00:00','yyyy-MM-dd HH24:mi'),'hh24mi') >='0000'                   and to_date(to_char('2007-08-31 00:00:00','yyyy-MM-dd HH24:mi'),'hh24mi')<='0200'  
                      then 1  else null end ) 
                      from case_info where type='盗窃' sql运行,报错:“ORS-01722 无效数字”
      

  5.   

    看了你其他帖子,还没理解?
    count(case when 条件 then 1 else null  end)
    意思:如果符合条件,就记为1,不符合就是null(count不出来)也可以这样写
    sum(case when 条件 then 1 else 0 end)