解决方案 »

  1.   

    then后面只能有1个值,如果多个字段,需要分开写
    select case 字段1 when 'aa' then 字段2
                                 when  'bb' then 字段3
                                  else 字段5
                end,
                case 字段1 when 'aa' then 字段3 
                                 when  'bb' then 字段4
                                  else 字段6
                end 
    from 表
      

  2.   

    不知道你显示两列想达到什么效果,如果实在要显示两列,可以进行拼接:select case 字段1 when 'aa' then 字段2||字段3 
                                  when  'bb' then 字段3||字段4
                                   else 字段5||字段6
                 end  
     from 表
      

  3.   

    如果字段较多可以使用union all的方式进行查询select 字段2,字段3 from 表 where 字段1= 'aa' 
    union all
    select 字段3,字段4 from 表 where 字段1= 'bb' 
    union all
    select 字段5,字段6 from 表 where 字段1 not in ('aa' ,'bb')
      

  4.   

    select 字段2,字段3 from 表 where 字段1= 'aa' 
    union all
    select 字段3,字段4 from 表 where 字段1= 'bb' 
    union all
    select 字段5,字段6 from 表 where 字段1 not in ('aa' ,'bb')
    联合查询