TABLE     FIELD1,  FIELD2  (字段类型为BOOL)
            0        1
            1        1
有没办法求这两条记录的或结果?
加的话可以用SUM().有没求或的函数呢?

解决方案 »

  1.   

    declare @t table(a bit,b bit)
    insert into @t select 0,1
    insert into @t select 1,1
    insert into @t select 0,0select a,b,a|b from @t
    --这样?
      

  2.   

    create table m(a bit,b bit)
    insert into m values(1,0)
    insert into m values(0,1)
    insert into m values(1,1)
    insert into m values(0,0)select a,b, a^b 
    from m
    结果:
    a    b         
    ---- ---- ---- 
    1    0    1
    0    1    1
    1    1    0
    0    0    0(所影响的行数为 4 行)
      

  3.   

    create table m(a bit,b bit)
    insert into m values(1,0)
    insert into m values(0,1)
    insert into m values(1,1)
    insert into m values(0,0) select a,b, a|b 
    from m
      

  4.   

    declare @t table(a bit,b bit)
    insert into @t select 0,1
    insert into @t select 1,1
    insert into @t select 0,0
    insert into @t select 1,0select a,b,a|b from @t
    --弄个完整的
      

  5.   

    declare @t table(a bit,b bit)
    insert into @t select 0,1
    insert into @t select 1,1
    insert into @t select 0,0select a,b,a|b from @t
    --这样?
    错错错!!!!不是列之间的或运算.
    是记录集结构某一个列的或运算
      

  6.   

    create table #t1(col1 bit,col2 bit)
    insert #t1
    select 0,1
    union 
    select 1,0
    union 
    select 0,0
    union
    select 1,1
    select result=case when (col1<>0 or col2<>0) then 1 else 0 end from #t1
      

  7.   

    create table #t1(col1 bit,col2 bit)
    insert #t1
    select 0,1
    union 
    select 1,0
    union 
    select 0,0
    union
    select 1,1
    select result=case when (col1<>0 or col2<>0) then 1 else 0 end from #t1
    这位你好像也把两个列拿来或运算了.跟第一个一样.不是我要的
    我是说我想把select出来的两条记录的相同一个字段进行或运算.不知你们还懂我的意义了么?
    SUM(某列)你们知道是怎么加的么?就像SUM一样的意思.