select case company_kind when 1  then '国有' 
                         when 2  then '私有'
                         when 3  then '外企'
       end ,isnull(phone_q,'')+'-'+isnull(company_phone,'')
from 表

解决方案 »

  1.   

    select case company_kind when 1 then '国有'
                             when 2 then '私有'
                             when 3 then '外企'
             phone_q+'-'+company_phone
    from A
      

  2.   

    select case a.company_kind
    when 1 then N'国有'
    when 2 then N'私有'
    when 3 then N'外企'
    end,
    rtrim(phone_q)+'-'+rtrim(company_phone)
    from A,B
    where 关联条件
      

  3.   

    忘记End了:(select case company_kind when 1 then '国有'
                             when 2 then '私有'
                             when 3 then '外企'
            end,
            phone_q+'-'+company_phone
    from A
      

  4.   

    1.select case company_kind when 1 then '国有' else company_kind end as company_kind,* from yourtable
      

  5.   

    1.select case company_kind when 1 then '国有' else company_kind end as company_kind,* from yourtable
      

  6.   

    select case company_kind when 1  then '国有' 
                             when 2  then '私有'
                             when 3  then '外企'
           end ,isnull(phone_q,'')+
                case when phone_q is null then '' else '-' end+
                isnull(company_phone,'')
    from 表
      

  7.   

    --或者:
    select substring(N'国有私有外企',a.company_kind*2-1,2),
    rtrim(phone_q)+'-'+rtrim(company_phone)
    from A,B
    where 关联条件
      

  8.   

    --或者:
    select substring(N'国有私有外企',a.company_kind*2-1,2),
    rtrim(phone_q)+'-'+rtrim(company_phone)
    from A,B
    where 关联条件
      

  9.   

    1. select ase company_kind when '1' then '国有'
                                 when '2' then '私有'
                                 when '3' then '外企'
               end from A表
    2.select phone_q+'-'+company_phone as phone-number from A表
      

  10.   

    select company_kind=case when company_kind=1 then '国有' when company_kind=2 then '私有' when company_kind=3 then '外企' end,phone=cast(phone_q as varchar)+'-'+cast(company_phone as varchar) 
    from tb
      

  11.   

    大家抢啊,呵呵select case A.company_kind when 1 then '国有'
                             when 2 then '私有'
                             when 3 then '外企'
             End ,
            convert(varchar(5),A.phone_q)+'-'+convert(varchar(10),A.company_phone) as PhoneNum
    from A,B
    where --关联条件
      

  12.   

    1. select case company_kind when '1' then '国有'
                                 when '2' then '私有'
                                 when '3' then '外企'
               end from A表
    2.select phone_q+'-'+company_phone as phone-number from A表
      

  13.   

    select  
    case a.company_kind
        when 1 then '国有'
        when 2 then '私有'
        when 3 then '外企'
    end as company_kind,
    a.phone_q+'-'+a.company_phone as phone
    from 
    A表 a, B表 b
    where 
             ...
      

  14.   

    感觉这种比较好用,如果万一国有私有外企又添加有得写一堆代码了。
    select substring(N'国有私有外企',a.company_kind*2-1,2),
    rtrim(phone_q)+'-'+rtrim(company_phone)
    from A,B
    where 关联条件
      

  15.   

    还有一点(3)B表中id2与A中id1相等,例如:B表中name值为,q1,q2,q3,对应的id2=100,A表中id1=100,想取出B表中的值怎么半
      

  16.   

    不太明白你的意思,给具体一点的
    select b.* from a,b where a.id1=b.id2
    是这个么?
    ------------------------------------------------------------------------------------
    还有一点(3)B表中id2与A中id1相等,例如:B表中name值为,q1,q2,q3,对应的id2=100,A表中id1=100,想取出B表中的值怎么半
      

  17.   

    select case a.company_kind
    when 1 then N'国有'
    when 2 then N'私有'
    when 3 then N'外企'
    end,
    rtrim(phone_q)+'-'+rtrim(company_phone)
    from A,B
    where 关联条件
    这么我看不到星星?