SQL 类似switch的东东用法

例子一:

select getdate() as '当前时间',
    case month(getdate())
        when 9 then '9月份'
        when 10 then '10月份'
        else convert(varchar(50), month(getdate()))
    end

例子二:

select getdate() as '当前时间',
    case 
        when month(getdate()) = 9 then '9月份'
        when month(getdate()) = 10 then '10月份'
        else convert(varchar(50), month(getdate()))
    end

 

posted @ 2016-09-12 10:34  鞍山老菜鸟  阅读(1304)  评论(0编辑  收藏  举报