if exists(select * from tablename where colum4<>'0')
  select * from tablename where colum4='0'
else
  select *from tablename where '1'='2'
不知道理解是否正确!

解决方案 »

  1.   

    select a,b,c,min(filed4) from tb group by a,b,c
      

  2.   

    理解错误
    如何查找一个表中部分相同的记录,如果部分相同的记录不存在,则查找出来!!! 而且colume4的值不确定的啊,我只是列个例子出来
      

  3.   

    select 
        a.* 
    from 
        tablename a 
    where 
        not exists(select 1 from tablename where col1=a.col1 or col2=a.col2 or col3=a.col3 or col4=a.col4)
      

  4.   

    select 1 from tablename 中1是什么意思?
      

  5.   

    select a.* from tablename a,
     (select b.fld1,b.fld2,b.fld3 from tablename b
       group by b.fld1,b.fld2,b.fld3 
        having count(*) = 1) c
    where a.fld1 = c.fld1
     and  a.fld2 = c.fld2
     and  a.fld3 = c.fld3
    --把tablename和fld1/2/3 替换成目标表和对应的字段
      

  6.   

    参考下面贴子中的表结构:
    http://community.csdn.net/Expert/topic/3810/3810928.xml?temp=.1188166
    执行:
    select distinct a1.a,a2.b,a3.c,a4.d
    from a a1,a a2,a a3,a a4
    where a1.a=a2.a
    and a1.a=a3.a
    and a1.a=a4.a
    and a1.b=a2.b
    and a1.b=a3.b
    and a1.b=a4.b
    and a1.c=a2.c
    and a1.c=a3.c
    and a1.c=a4.c
    and a1.d=0
    and a2.d=0
    and a3.d=0
    and a4.d=0;
    结果:
    A          B          C                   D
    ---------- ---------- ---------- ----------
    a          b          b                   0
    a          b          c                   0
    b          b          c                   0