select sum(number) from t where to_number(to_char(date,'yyyymmhh24')) between 20120718 and 20120720
select sum(number) from t where to_number(to_char(date,'yyyymmhh24')) between 20120718 and 20120720
12年7月份18点到20点的number总和 建议使用to_char实现 to_char(date,'yyyy-mm')='2012-07' to_char(date,'hh24')>=18 and to_char(date,'hh24')<=20 即:select sum(number) from 表名 where to_char(date,'yyyy-mm')='2012-07' and to_char(date,'hh24')>=18 and to_char(date,'hh24')<=20
建议使用to_char实现
to_char(date,'yyyy-mm')='2012-07'
to_char(date,'hh24')>=18 and to_char(date,'hh24')<=20
即:select sum(number) from 表名 where to_char(date,'yyyy-mm')='2012-07' and
to_char(date,'hh24')>=18 and to_char(date,'hh24')<=20