www.1862.net > sql sErvEr 查询重复数据(iD不重复)

sql sErvEr 查询重复数据(iD不重复)

select id, name, memo from A where id in (select id from A group by id having count(1) >= 2)

可以先用distinct去重复,然后在把别的删了。 比如:delete from a where id not in(select distinct * from a)

友善的提醒两点,如有帮助还望采纳,谢谢! 第一、你这个语句本身写的有点麻烦,简化如下 SELECT [Store_Abbreviation] ,[Goodname], [Goodmodel] ,SUM(Order_Quantity) AS Order_Quantity, [Workid]from [fangtaidata].[dbo].[SalesStatistics]...

select id,name,age from 表 group by id,name,age having count(1)>=2

SELECT * FROM tablea WHERE (number NOT IN (SELECT ta.number FROM tablea AS ta INNER JOIN tablea AS tb ON ta.number = tb.number AND ta.id tb.id))

这说明你的同一个版本里有不同的ID,所以,你要决定一下,同一个版本里的多个ID,你是要取最大的,还是最小的,ID怎么取的问题。然后,就可以排序了。 如: SELECT 版本,max(id) id FROM 表 GROUP BY 版本 order by id desc

关键字Distinct 去除重复,如下列SQL,去除Test相同的记录; select distinct Test from Table 如果是要删除表中存在的重复记录,那就逻辑处理,如下: select Test from Table group by Test having count(test)>1 先查询存在重复的数据,后面...

select * from table a where exists (select 1 from table group by name,sex,age having min(id)=a.id)

不查ID 之后 group by 或者 max(id) 取一个就好

不明白你到底要实现什么... 补充: select replyorder.*,revisitlist.* from replyorder inner join (select 单据编号,回访编号=min(回访编号) from revisitlist group by 单据编号)as a on a.单据编号=replyorder.单据编号 inner join revisitli...

网站地图

All rights reserved Powered by www.1862.net

copyright ©right 2010-2021。
www.1862.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com