重复记录的操作

一:查询

1.查询出表中某个字段重复的记录

select * from table where ttt in (select ttt from  table group by ttt  table where count(ttt)>1)

2.查询表中字段和另一张表字段值相同的记录

select * from table where ttt in (select ttt_1 from table_1 group by ttt_1 where count(ttt_1)>1 )

3.查询出无重复记录的结果(例如:两条完全相同的记录,只取一条)

select distinct * from  table 

4查询某个字段值不重复的记录(例如,GoodsType字段是重复的)

SELECT
      *

  FROM dbo.Master_Goods where GoodsID in(select max(GoodsID) from [dbo].[Master_Goods] group by GoodsType)

待续。。。。

 

posted @ 2012-03-13 21:51  偶不是大叔  阅读(116)  评论(0)    收藏  举报