首页 > 开发 > 综合 > 正文

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

2024-07-21 02:11:31
字体:
来源:转载
供稿:网友

解决数据库中记录重复问题 (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)
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表