您的位置:首页 > 数据库 > Oracle

Oracle decode使用

2017-03-03 18:02 399 查看
两个门  进出 一共四个方向  根据日期 对四中情况 就行数量统计

   select

      count(t.type_0) ,

      count(t.type_1) ,

      count(t.type_2),

      count(t.type_3),

      t.time      

        from

            (      

             select

             c.carsno,

             DECODE(c.gateid,'南门入口','南门入口') as type_0,

             DECODE(c.gateid,'南门出口','南门出口') as type_1,

             DECODE(c.gateid,'东门出口','东门出口') as type_2,

             DECODE(c.gateid,'东门入口','东门入口') as type_3,  

             substr(c.outintime,9,2) as time

                from cars_inoutlog c

             where

                 c.outintime like '%2017-01%'

             order by c.outintime

             ) t                        

group by t.time

order by t.time

            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: