字段a,b 
值:1,2
1,4
1,2
1,3
想找出1,4和1,3的两条记录,sql如何写呀?

解决方案 »

  1.   

    你都沒規則怎麼寫。
    select a,b from table where b<>2
      

  2.   

    難道是找出b不重復的?Select * From 表 Where b Not In (Select b From 表 Group By b Having Count(b) > 1)
      

  3.   

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

  4.   

    xubt(未成功) ( ) 信誉:100  2007-08-09 09:08:22  得分: 0  
     
     
       是找出,a,b两个字段同时都不重复的记录
      
     
    ---------------------------
    同時不重復?理解錯了。也寫個。 :)Select a, b from 表 Group By a,b having count(a) = 1
      

  5.   

    Select a, b Into NewTableName from 表 Group By a,b having count(a) = 1
    然後就可以查詢Select * From NewTableName
      

  6.   

    select a,b into tblname from t group by a,b having count(*)=1
      

  7.   

    try
    Select * Into NewTableName from 表 
    Where 主鍵
    In (Select 主鍵 From 表 Group By a,b having count(a) = 1)
      

  8.   

    Select 主鍵 From 表 Group By a,b having count(a) = 1,
    这一句在运行时就有错,提示需要在group by中增加主键,可是我一增加,查询出来的记录数就不对了
      

  9.   

    不好意思,少寫點一個函數Select * Into NewTableName from 表 
    Where 主鍵
    In (Select Min(主鍵) From 表 Group By a,b having count(a) = 1)
      

  10.   

    Select a, b Into NewTableName from 表 Group By a,b having count(a) = 1
      

  11.   

    好了,谢谢.paoluo(一天到晚游泳的鱼)
      

  12.   

    樓主,你的問題如果解決了,請結貼。你在SQL版幾個月前的帖子,都沒有結掉。