如果一个字段final 有五种状态,分别为1,2,3,4,5,
这五种状态分别对应不同的五个值,A,B,C,D,E,F查询时,要输出对应的五种值,在一个字段
即   ```    final    ```      A
    ``````   C    `````    D

解决方案 »

  1.   

    表A字段为Final
    表B为CHAselect A.Final,B.cha FROM A,B  where A.final = B.对应字段
      

  2.   

    case final when 1 then 'A'
    when 2 then 'B'
    end
      

  3.   

    --这样?
    declare @t table(final int,duiying varchar(10))
    insert into @t select 1,'A'
    union all select 2,'B'
    union all select 3,'C'
    union all select 4,'D'
    union all select 5,'E'select max(case final when 1 then 'A' end) from @t union all
                  select max(case final when 2 then 'B' end) from @t union all
                  select max(case final when 3 then 'C' end) from @t union all
                  select max(case final when 4 then 'D' end) from @t union all
                  select max(case final when 5 then 'E' end) from @t