• Case SQL statements of Usage


    Code as below:

    Remark by Jimmy Jun 20th 2010

    代码
    1、无标题

    select ltrim(a.prodid),

    case ProdStatus

    when 0 then '已创建' when 1 then '已估计'

    when 2 then '已计划' when 3 then '已发放'

    when 4 then '已开始' when 5 then '生产入库'

    when 6 then '成本已核算'when 7 then '已结束' end

    ,a.createddate,b.
    [name]

    from prodtable a

    -------------------------------------



    2、有标题一

    select ltrim(a.prodid),'工单状态' =

    case ProdStatus

    when 0 then '已创建' when 1 then '已估计'

    when 2 then '已计划' when 3 then '已发放'

    when 4 then '已开始' when 5 then '生产入库'

    when 6 then '成本已核算'when 7 then '已结束' end

    ,a.createddate,b.
    [name]

    from prodtable a

    -------------------------------------

    3、有标题二



    select ltrim(a.prodid),

    case ProdStatus

    when 0 then '已创建' when 1 then '已估计'

    when 2 then '已计划' when 3 then '已发放'

    when 4 then '已开始' when 5 then '生产入库'

    when 6 then '成本已核算'when 7 then '已结束' end AS '工单状态'

    ,a.createddate,b.
    [name]

    from prodtable a

    -------------------------------------

    4、有标题,但没有省略

    select ltrim(a.prodid),

    '工单状态' = case

    when ProdStatus = 0 then '已创建' when ProdStatus = 1 then '已估计'

    when ProdStatus = 2 then '已计划' when ProdStatus = 3 then '已发放'

    when ProdStatus = 4 then '已开始' when ProdStatus = 5 then '生产入库'

    when ProdStatus = 6 then '成本已核算' when ProdStatus = 7 then '已结束' end

    ,a.createddate,b.
    [name]

    from prodtable a
  • 相关阅读:
    java 多线程
    构造N位格雷码(递归,面向对象)
    字典树trie
    快速排序
    C++ 链表
    15-谜问题(深拷贝、LC检索、面向对象编程)
    [编程题] 扫描透镜(本题还涉及如何从字符串中提取数字)
    python爬虫提取冰与火之歌五季的种子
    带有限期和效益的单位时间的作业排序贪心算法
    0/1背包问题与动态规划
  • 原文地址:https://www.cnblogs.com/Fandyx/p/1761218.html
Copyright © 2020-2023  润新知