问答详情
源自:6-12 case...when语句

写一下语句,加深记忆

select case column_name1 

    when value1 then result1 

    [when value2 then result2.....][else result] 

    end [as column_new_name]

    [,case 

     when expr1 then result1 

    [when expr2 then result2...]

    [else result] 

    end [as column_new_name]

    [,case...]

    ]

from tb_name;


提问者:180416 2018-11-30 16:51

个回答

  • 莫失聪聪3779259
    2018-12-05 17:30:35

    select case column_name1

    when value1 then result1

    [when value2 then result2.... ][else result]

    end [as column_new_name]

    [,case 

    when expr1 then result1

    [when expr2 then result2...]

    [else result]

    end [as column_new_name]

    [,case...]

    ]

    from tb_name;