zoukankan      html  css  js  c++  java
  • 关于sql语句里根据状态显示对应信息

    1,    case..when...then..

    例:select a.id,(case a.station where 0 then "正常"

                                                     where 1 then "异常"

                                                    else "未统计入库"

                                                    end

                             ) 状态  from factory a;

    2,      IF(expr1,expr2,expr3)

    例:

    SELECT IF(a.sex=1,"男","女") AS s FROM table a 
    WHERE sex != '';

    3,   count(case when expr1 then 1 end)arg1

    select  count(case  when a.ststion=0 then 1 end)正常,

              count(case when a.station=1 then 1 end)异常,

               count(case when a.station<>0 and a.station<>1 then 1 end ) 未统计入库 

              from table a;                    

                 




  • 相关阅读:
    bzoj 4610 Ceiling Functi
    uva 01350
    uva 12075
    uva 01393
    uva 11038
    CF 496E
    CF 496D
    poj 3167
    hdu 4622
    spoj 7258
  • 原文地址:https://www.cnblogs.com/pureray-hui/p/12653214.html
Copyright © 2011-2022 走看看