我该怎么做才能将该组按值分成2:
e.g。
select avg(blocks),to_char(dat,'yy-mm-dd hh24'),'small'/'big'
from tab
group by to_char(dat,'yy-mm-dd hh24'), (blocks case1 >1000, case2 <=1000)
表格标签:
id number
blocks number
dat date
表是:
ID BLOCKS DAT
--- ------- --------
1 2 14-02-19 14:01:00
2 2 14-02-19 14:02:00
3 2000 14-02-19 14:03:00
4 3000 14-02-19 14:04:00
结果:
2 14-02-19 14 small
2500 14-02-19 14 big
答案 0 :(得分:0)
您需要case
声明:
select avg(blocks), to_char(dat,'yy-mm-dd hh24')
from tab
group by to_char(dat,'yy-mm-dd hh24'),
(case when blocks > 1000 then 1
else 2
end);