oracle 中decode的用法

 select   decode(gg1.group_goods_amount,
                            0,
                            1,
                            gg1.group_goods_amount) from goods_group_item  gg1  where gg1.GROUP_ITEM_ID=4407;

这句话的意思是:如果group_goods_amount为0 则取值为1,否则取group_goods_amount的数据库值

 select
           g.order_shipping_com as "logisticsCompanyCode",
           k.company_name as "logisticsCompany",
           g.order_shipping_nu  as "logisticsNumber",
           g.order_shipping_orderid as "orderId",
           i.COMMIT_TIME            as "orderTime",
           decode(i.ORDER_STATE,18,'已退款',19,'退货完成',20,'退货中',
           21,'已出库',22,'配货中',23,'已收货',24,'缺货中',25,'已取消',
           26,'已完成',27,'已发货',431,'部分发货',28,'已审核',29,'已提交','其他') as "orderStatus"
    from  fec.order_shipping_log g , order_info i,KD100_LOGISTICS_COMPANY k
    where g.order_shipping_orderid = i.ORDER_ID(+)
          and g.order_shipping_com = k.company_no(+)
          and g.order_shipping_orderid = #{orderId}
    group by k.company_name,g.order_shipping_nu,g.order_shipping_orderid,i.ORDER_STATE,i.COMMIT_TIME,g.order_shipping_com

 

上一篇:MySql多列转行


下一篇:C# 设计模式(11)外观模式