Oracle 分组查询以分钟为单位
答案:2 悬赏:70
解决时间 2021-02-07 22:49
- 提问者网友:星空下的寂寞
- 2021-02-07 10:55
Oracle 分组查询以分钟为单位
最佳答案
- 二级知识专家网友:丢不掉的轻狂
- 2021-02-07 11:21
这个问题得值300分啊。
写了一段代码,你可以试试。
select btime,etime,count(1)
from
(select '1'custno, to_date('2014-02-10 10:00:00','yyyy-mm-dd HH24:mi:ss')trxtime from dual
union all
select '1'custno, to_date('2014-02-10 10:11:00','yyyy-mm-dd HH24:mi:ss')trxtime from dual
)a --交易表
join
(select my_date+(rn-1)/(24*6) btime,my_date+rn/(24*6)etime
from
(select rownum rn from dual connect by rownum<=24*6 )temp1,
(select to_date('2014-2-8','yyyy-mm-dd')+rownum-1 my_date from dual
connect by rownum<=4
)temp2
)--构造的时间分段表
on a.trxtime >btime and a.trxtime<=etime
group by btime,etime;
--24*6 即是10分钟为单位, 通过设置可获得任意时间的间隔
写了一段代码,你可以试试。
select btime,etime,count(1)
from
(select '1'custno, to_date('2014-02-10 10:00:00','yyyy-mm-dd HH24:mi:ss')trxtime from dual
union all
select '1'custno, to_date('2014-02-10 10:11:00','yyyy-mm-dd HH24:mi:ss')trxtime from dual
)a --交易表
join
(select my_date+(rn-1)/(24*6) btime,my_date+rn/(24*6)etime
from
(select rownum rn from dual connect by rownum<=24*6 )temp1,
(select to_date('2014-2-8','yyyy-mm-dd')+rownum-1 my_date from dual
connect by rownum<=4
)temp2
)--构造的时间分段表
on a.trxtime >btime and a.trxtime<=etime
group by btime,etime;
--24*6 即是10分钟为单位, 通过设置可获得任意时间的间隔
全部回答
- 1楼网友:星痕之殇
- 2021-02-07 12:07
select class "班级",
case
when score > 85
then '高于85分,优秀'
when score <=85 and score >=60 then '60到85之间,及格'
else '低于60,不及格' end "分档",
sum(score) "总分",
count(1) "人数"
from score
group by
class,
case
when score > 85
then '高于85分,优秀'
when score <=85 and score >=60 then '60到85之间,及格'
else '低于60,不及格' end
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |