• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

解决数据库中记录重复问题_sqlserver

sqlserver 搞代码 3年前 (2018-06-16) 130次浏览 已收录 0个评论

解决数据库中记录重复问题 (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)

欢迎大家阅读《解决数据库中记录重复问题_sqlserver,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址