有一个表,很多字段,我想选出某一个字段(A)没有重复的记录,请问SQL如何写?

解决方案 »

  1.   

    select * from table t where (select count(1) from table where a=t.a)<2
      

  2.   

    select * from tablename where (select count(字段) from table group by 字段)<2
      

  3.   

    select * 
    from tbname t 
    where (select count(*) from tbname where A=t.A)=1
      

  4.   

    我这样写
    select * from file_info_tab_pc
    where
    (select count(*) as c from file_info_tab_pc group by soft_id) = 1但提示
    single-row subquery returns more then one row
      

  5.   

    应该如下写法:
    select * 
    from pos_xsls a --pos_xsls a你想要取数据的表
    where 
    (select count(*) 
      from pos_xsls b  --pos_xsls b你想要取数据的表
       where a.xsdbh=b.xsdbh )=1 
    order by xsdbh  --xsdbh 被检查重复的某一个字段
    哥们,请给我分哈,哈哈,如有什么问题的话请给我来信
      

  6.   

    试试
    Select * from 
    from file_info_tab_pc
    Where not 
    soft_id in
    (select soft_id from file_info_tab_pc
    group by soft_id 
    having count(*)>1 
    )
      

  7.   


    select * from  TheCode where 你的不重复字段  in 
    (
    select 你的不重复字段 from TheCode group by Code having Count(*)=1 --找出不重复字段
    )
      

  8.   

    是这样的吗?
    declare @t table(id int, num int)
    insert into @t 
    select 1,1
    union all select 2,1
    union all select 3,2
    union all select 4,2
    union all select 5,3select * from @t where id in (select max(id) from @t group by num having(count(num)<2))
      

  9.   

    用一个DISTINCT关键字不就完了````搞那么麻烦```
      

  10.   

    上面应该有楼主的答案了select * from file_info_tab_pc
    t where (select count(*) from file_info_tab_pc
    where A=t.A)=1
      

  11.   

    select * 
    from tbname t 
    where (select count(*) from tbname where A=t.A)=1
    其实这个就是把不重复的记录显示出来的吧.
      

  12.   

    select * from tb1 having count(A)=1
      

  13.   

    select a,count(b) from 表 group by a having count(b)=1