select hm,trunc(to_date(calling_date||' '||calling_time,'yyyymmdd hh24miss')-0.5) ,sum(fy) from test 
group by hm, trunc(to_date(calling_date||' '||calling_time,'yyyymmdd hh24miss')-0.5)

解决方案 »

  1.   

    to czbbbs(强弩):
    不用改呀,譬如你住酒店,一般都是当天的中午12点到第2天的中午12点,统计这段时间你消费的钱。
      

  2.   

    select hm,
           (case when to_number(calling_time) < 115959 then calling_date - 1 else calling_date end) calling_date ,
           sum(fy)
    from test
    group by  hm,
           (case when to_number(calling_time) < 115959 then calling_date - 1 else calling_date end)