我希望如此,我在一列所有的结果,而不是单独的4对到那些下面的SQL语句组合:结合SQL语句和包括时间字符串范围
select count(incnum) as counttenth3 from kincident where (to_char(reportdate,'hh24') between 0 and 2.59 or to_char(reportdate,'hh24') between 21 and 23.59
select count(incnum) as counttenth2 from kincident where to_char(reportdate,'hh24') between 15 and 20.59
select count(incnum) as counttenth1 from kincident where to_char(reportdate,'hh24') between 9 and 14.59
select count(incnum) as counttenth0 from kincident where to_char(reportdate,'hh24') between 3 and 8.59
唯一的区别是每个陈述的时间范围。 因此,我试图将它们合并为一列,并且我希望第二列包含给定字符串的行(不是来自数据库)
例如,
Timing | count of incidents
-----------------------------
morning | 26
afternoon | 35
night | 40
所以,你要想想这2个步骤 - 类别到您的时间 – 2014-10-28 06:57:21
的类别,然后将范围组@ChrisMoutray这是我遇到的麻烦是什么,我不知道如何为某个时间范围分配一个类别。我所拥有的就是个人4条语句,每条语句都是[早,午,晚,午夜]之一] – AuthenticReplica 2014-10-28 07:01:49