有张表,里面有号码和访问时间两列,例如;phone                time15305689584       2011-10-31 01:25:13
....
现在需要将这个表中数据分类,按每15分钟分一类,语句改怎么写在线等

解决方案 »

  1.   

    表 只有两列,一个是varchar,一个是时间格式
      

  2.   

    select TRUNC(time, 'HH24') + FLOOR((to_char(time, 'MI') / 15)) / 96,count(*)
    from tab 
    group by TRUNC(time, 'HH24') + FLOOR((to_char(time, 'MI') / 15)) / 96
      

  3.   


    select count(phone) as vist_num,trunc(time,'hh')||'00--15'
    from table_name
    where to_char(time,'mi')>='00' and to_char(time,'mi')>='15'
    group by trunc(time,'hh')
    union
    select count(phone) as vist_num,trunc(time,'hh')||'16--30'
    from table_name
    where to_char(time,'mi')>='16' and to_char(time,'mi')>='30'
    group by trunc(time,'hh')
    ....