有一个表a
字段b 和c
c字段是时间,比如13:25:00
b字段是id,现在我想查询一下每十分钟有多少个ID,语句该怎么写?

解决方案 »

  1.   

    select substr(c,1,4) c,count(*) count
    from tb
    group by substr(c,1,4)
      

  2.   

    desc table
    看一下是什么类型的
      

  3.   

    可以用下面命令查看表的数据类型
    desc 表名显示格式为:13:21:25,有可能前面还有日期,那就是timestamp类型;
    有可能是实际存储内容为:13:21:25,那就是varchar2类型;可以这样试试
    select substr(c,1,15) c,count(*) count 
    from (select to_char(c,'YYYY-MM-DD HH24:MM:SS') c ,id from tb)
    group by substr(c,1,15);
      

  4.   

    那个,我先说一下思路吧把最小的日期和最大的日期算下来,看有多少分钟,然后将其乘以‘0.1’,然后再用总数数以这个数就可以了Select count(*)/((max(c) - min(b))*24*3600/6) from a
      

  5.   

    哦,不好意思,写错了,应该是这样的
    Select count(*)/((max(c) - min(c))*24*3600/6) from a
      

  6.   


    老大正解啊!我来补充下,更完善显示的是哪个时间段的统计!select substr(c,1,4)||"0--"||substr(c,1,4)||"9" c,count(*) count 
    from tb 
    group by substr(c,1,4)