请问 如何  分组 判断  实现 "与" 判断  真假  ???? 急!!!!!!!!!!!!!!!!!!!!例如表的内容 如下:
ID(自动编号)         组ID               真假(类型为 BIT )   1                     1                  1
2                     1                  03                     2                  1
4                     2                  15                     3                  1
6                     3                  0
7                     3                  1
现在按  "组ID"  字段 分组  ,分组后 按 "真假" 字段 进行  "与" 合并 ,得出 如下 结果:组ID               真假(类型为 BIT )   1                    02                    13                    0

解决方案 »

  1.   

    select 组ID,真假=(case when min(真假)=0 then 0 else 1 end)
    from 表
    group by 组ID 
    order by 组ID
      

  2.   

    select 组ID,真假=(case when min(cast(真假 as int))=0 then 0 else 1 end)
    from 表
    group by 组ID 
    order by 组ID
      

  3.   

    create table a
    (ID int ,组ID  int,真假 bit) 
    insert a
    select 1                     ,1                  ,1
    union all
    select 2                     ,1                  ,0
    union all
    select 3                     ,2                  ,1
    union all
    select 4                     ,2                  ,1
    union all
    select 5                     ,3                  ,1
    union all
    select 6                     ,3                  ,0
    union all
    select 7                     ,3                  ,1
    select distinct s.组ID,s.真假&t.真假 as 真假  from a s join a t on s.ID =t.ID-1组ID         真假   
    ----------- ---- 
    1           0
    2           1
    3           0(所影响的行数为 3 行)