zoukankan      html  css  js  c++  java
  • Sql server if-else以及switch

    --相当于C#中的if-else 根据levle列的值来判断自定义列显示的内容
    --要求then后面的数据类型必须一致

    select * ,头衔=case
    when [levle]=1 then '菜鸟'
    when [levle]=2 then '老鸟'
    when [levle]=3 then '大师'
    else '骨灰级'
    end
    from [user];

    --相当于C#中的switch

    select * ,头衔=case [levle]
    when 1 then '菜鸟'
    when 2 then '老鸟'
    when 3 then '大师'
    else '骨灰级'
    end
    from [user];

    select * from tblscore;

    select tScoreId,tSId,tEnglish,等级=case
    when tEnglish>=95 then '优'
    when tEnglish>=80 then '良'
    when tEnglish>=70 then '差'
    when tEnglish<60 then '不良格'
    else '不良格'
    end
    from dbo.TblScore

  • 相关阅读:
    python项目文件夹
    内置函数
    函数的递归
    python入门之模块
    匿名函数
    生成器表达式
    三元表达式
    列表生成式
    input相关问题总结
    表单验证
  • 原文地址:https://www.cnblogs.com/jiangyunfeng/p/9000986.html
Copyright © 2011-2022 走看看