where fdarrivetime between to_date('2007-7-24 0:00:00','yyyy-MM-dd hh24:mi:ss')
and to_date('2007-8-24 0:00:00','yyyy-MM-dd hh24:mi:ss')
这是我的SQL语句
我要查包裹每天的的数量根据时间
并且要按天分组
麻烦各位帮帮我
很急的
先谢谢各位啦!
明天接贴
4 个解决方案
#1
这样写就可以根据天分组了
select count(fdpackagecode) count,to_char(fdarrivetime ,'yyyy-MM-dd') time from tblcs_package where fdarrivetime between to_date('2007-7-24 0:00:00','yyyy-MM-dd hh24:mi:ss') and to_date('2007-8-24 0:00:00','yyyy-MM-dd hh24:mi:ss') Group by to_char(fdarrivetime ,'yyyy-MM-dd')
select count(fdpackagecode) count,to_char(fdarrivetime ,'yyyy-MM-dd') time from tblcs_package where fdarrivetime between to_date('2007-7-24 0:00:00','yyyy-MM-dd hh24:mi:ss') and to_date('2007-8-24 0:00:00','yyyy-MM-dd hh24:mi:ss') Group by to_char(fdarrivetime ,'yyyy-MM-dd')
#2
select count(fdpackagecode) count,fdarrivetime time from tblcs_package
where fdarrivetime between to_date('2007-7-24 0:00:00','yyyy-MM-dd hh24:mi:ss')
and to_date('2007-8-24 0:00:00','yyyy-MM-dd hh24:mi:ss') group by (case when to_char(fdarrivetime ,'hh24') <= '24' then trunc(fdarrivetime ) else trunc(fdarrivetime ) + 1 end)
where fdarrivetime between to_date('2007-7-24 0:00:00','yyyy-MM-dd hh24:mi:ss')
and to_date('2007-8-24 0:00:00','yyyy-MM-dd hh24:mi:ss') group by (case when to_char(fdarrivetime ,'hh24') <= '24' then trunc(fdarrivetime ) else trunc(fdarrivetime ) + 1 end)
#3
没用过ORACLE 学习接分中
#4
group by to_date( "2007-8-24", "yyyy-MM-dd")
#1
这样写就可以根据天分组了
select count(fdpackagecode) count,to_char(fdarrivetime ,'yyyy-MM-dd') time from tblcs_package where fdarrivetime between to_date('2007-7-24 0:00:00','yyyy-MM-dd hh24:mi:ss') and to_date('2007-8-24 0:00:00','yyyy-MM-dd hh24:mi:ss') Group by to_char(fdarrivetime ,'yyyy-MM-dd')
select count(fdpackagecode) count,to_char(fdarrivetime ,'yyyy-MM-dd') time from tblcs_package where fdarrivetime between to_date('2007-7-24 0:00:00','yyyy-MM-dd hh24:mi:ss') and to_date('2007-8-24 0:00:00','yyyy-MM-dd hh24:mi:ss') Group by to_char(fdarrivetime ,'yyyy-MM-dd')
#2
select count(fdpackagecode) count,fdarrivetime time from tblcs_package
where fdarrivetime between to_date('2007-7-24 0:00:00','yyyy-MM-dd hh24:mi:ss')
and to_date('2007-8-24 0:00:00','yyyy-MM-dd hh24:mi:ss') group by (case when to_char(fdarrivetime ,'hh24') <= '24' then trunc(fdarrivetime ) else trunc(fdarrivetime ) + 1 end)
where fdarrivetime between to_date('2007-7-24 0:00:00','yyyy-MM-dd hh24:mi:ss')
and to_date('2007-8-24 0:00:00','yyyy-MM-dd hh24:mi:ss') group by (case when to_char(fdarrivetime ,'hh24') <= '24' then trunc(fdarrivetime ) else trunc(fdarrivetime ) + 1 end)
#3
没用过ORACLE 学习接分中
#4
group by to_date( "2007-8-24", "yyyy-MM-dd")