A表
A数量      A日期      B数量      B日期
1 20060929     9    20060929
2 20060928
    6    20060805
    8    20060909
    2    20060925
8        20060901     执行语句之后变成:
A数量     B数量      B日期
1  9    20060929
2             20060928
          6    20060805
 8    20060909
          2    20060925
8                    20060901

解决方案 »

  1.   

    A表
    A数量      A日期      B数量      B日期
    1 20060929     9    20060929
    2 20060928
        6    20060805
        8    20060909
        2    20060925
    8        20060901     执行语句之后变成:
    A数量     B数量      B日期
    1         9          20060929
    2                    20060928
              6          20060805
              8          20060909
              2          20060925
    8                    20060901
      

  2.   

    select A数量,,B数量,B日期 from A不就可以了吗
    好奇怪的需求
      

  3.   

    select A数量,B数量,B日期 from A
    那么B日期列就会空了20060928、20060901
      

  4.   

    select A数量,B数量,case when B日期='' then A日期else B日期end
    from A
      

  5.   

    select A数量,B数量,case when B日期='' then A日期 else B日期 end
    from A
      

  6.   

    select A数量,B数量,日期= case when B日期 is null then A日期 else B日期 end 
    from table
      

  7.   

    select A数量,B数量,case when B日期=''  then A日期 else B日期 end
    from A
      

  8.   

    select A数量,B数量,ISNULL(A日期,B日期) AS B日期 from A表
      

  9.   

    declare @a table(a数量 int ,A日期 char(8),B数量 int,B日期 char(8))
    insert into @a select 1, '20060929',     9,    '20060929'
    union all      select 2 ,'20060928',null,null
    union all      select null,null,6,    '20060805'
    union all      select null,null,8 ,   '20060909'
    union all      select null,null,2,    '20060925'
    union all      select 8, null,  null,     '20060901'    
    select a数量,B数量,coalesce(A日期,B日期 )as B日期 from @a