id为空是,赋值为200
id为Null是,赋值为100
否则查出id的值
语句该怎么写?
select (case id when id is null then 100 when id='' then 200 else id end ) from mytable

解决方案 »

  1.   


    select 
    (case  when id is null then 100 
           when id='' then 200 
           else id end 
     ) 
    from mytable
      

  2.   

    select (case when id is null then 100 when id='' then 200 else id end ) from mytable
      

  3.   


    select case when id is null then 100 when id='' then 200 else id end as id from mytable
      

  4.   

    id为空是,赋值为200 
    id为Null是,赋值为100 
    否则查出id的值 
    语句该怎么写? 
    select (case id when id is null then 100 when id='' then 200 else id end ) from mytableselect case when id = '' then 200 
                when id is null then 100
                else id
           end
    from mytable
      

  5.   

    select case when id is null then 100 when id='' then 200 else id end as id from mytable