有一堆数据。我想写个SQL语句,查出的结果是0-4点的,4-8点的,8-12点的一次类推。select time,count(*) from table group by time order by time类似的哦
最终查出的结果是:0-4 5
4-8 8 等等
后面的是我虚拟的count。不一定是time 但肯定是数字。select time,count(*) from table group by time order by time
单纯按照这种查他仅仅显示是同一时间的数量。所以 想弄时间段里的,希望知道的告诉我。谢谢哦
最终查出的结果是:0-4 5
4-8 8 等等
后面的是我虚拟的count。不一定是time 但肯定是数字。select time,count(*) from table group by time order by time
单纯按照这种查他仅仅显示是同一时间的数量。所以 想弄时间段里的,希望知道的告诉我。谢谢哦
解决方案 »
- ibatis框架运用报错,在线坐等高玩指导
- ODP.NET连接串的Connection Lifetime一般设置为多少合适呢?
- 重复数据怎样处理(提供一下思路即可谢谢)
- 求救关于oracle的数据库转移后的新库中使用sqlldr出错。
- Can't connect to X11 window server using '127.0.0.1:0.0' as the value of the DISPLAY variable.
- 菜鸟问题,望不吝赐教
- sys_connect_by_path用法问题,谢谢大家了!!
- 急,急,急,高分相送,创建表的问题???
- 游标最大可以有多少列?加急!!
- ◆◆◆大家帮忙!寻求现在企业还在使用的各种数据库系统不同版本的数据类型列表!只要您将下列数据库系统之一的数据类型发送给我,我将您
- 如何提高数据库插入更新操作的效率
- 跪求一sql查询语句
试试这样写
select trunc(time)+trunc((time-trunc(time))*6)/6,count(1)
from table1
group by trunc(time)+trunc((time-trunc(time))*6)/6
order by 1
(
select
case when time >= 0 and time < 4 then '0-4'
when time >= 4 and time < 8 then '4-8'
when time >= 8 and time < 12 then '8-12'
end time from table
) t
group by time
trunc(d1), round(to_number(to_char(d1,'HH24'))/4),count(*)
from
(
select sysdate d1 from dual
) a
group by trunc(d1), round(to_number(to_char(d1,'HH24'))/4)
最好给出完整的表结构,测试数据,计算方法和正确结果.发帖注意事项
http://topic.csdn.net/u/20091130/21/fb718680-98ff-4afb-98d8-cff2f8293ed5.html?24281
2楼是number型
用number来表示时间?好奇怪的做法