解决|数据|数据库|问题|重复
解决数据库中记录重复问题 (By:aloxy) Jul 22, 11:19 --产品数据重复统计SELECT mc, userid, COUNT(mc) AS Expr1FROM chanpinGROUP BY mc, userid--将不重复的纪录插入新表newchanpinselect * into #Tmp1 from chanpingoselect min(ID) as autoID into #Tmp2 from #Tmp1 group by mc, useridgoselect * into newchanpin from #Tmp1 where ID in(select autoID from #tmp2)--查找重复用户--select distinct name from user_nameselect * into #Tmp0 from user_namegoselect min(ID) as autoID into #Tmp6 from #Tmp0 group by admingoselect * into newuser_name from #Tmp0 where ID in(select autoID from #tmp6)--用户自定义类别SELECT userlb AS Expr1, userid AS Expr2, COUNT(userlb) AS Expr3FROM newuser_lbGROUP BY userlb, useridselect * into #Tmp8 from user_lbgoselect min(ID) as autoID into #Tmp9 from #Tmp8 group by userlb, useridgoselect * into newuser_lb from #Tmp8 where ID in(select autoID from #tmp9)--用户新闻select bt, userid,count(bt) from user_news group by bt,useridselect * into #Tmp88 from user_newsgoselect min(ID) as autoID into #Tmp99 from #Tmp88 group by bt,useridgoselect * into newuser_news from #Tmp88 where ID in(select autoID from #tmp99)