-2
중복을 계산하는 쿼리와 중복을 삭제하는 쿼리를 얻으려면 도와주십시오.중복을 계산하는 SQL 쿼리
중복을 계산하는 쿼리와 중복을 삭제하는 쿼리를 얻으려면 도와주십시오.중복을 계산하는 SQL 쿼리
나는 그래서 이것은 당신을 위해 일하는 오프 기회에서 How To Ask
를 참조하시기 바랍니다 모든 의견에 동의하고, 그것의 이익을 자신을 위해 좋은 훈련되고 그리고 여기,이에 비틀 거림에 다른 사람을 돕는 그것을 할 몇 가지 일반 코드는 다음과 같습니다
WITH CTE AS
(
SELECT
COALESCE(Col1,'') AS Col1,
COALESCE(Col2,'') AS Col2, ROW_NUMBER() OVER(PARTITION BY col1,col2 ORDER BY col1,col2) AS row_id
FROM MyTable
)
DELETE CTE WHERE row_id >1;
예 :
Create table #things (FirstName varchar(10), LastName varchar(10))
insert into #things (FirstName, LastName)
values('thing','lastthing'),('thing','lastthing'),('otherthing', 'something')
select * from #things
;WITH CTE AS
(
SELECT
COALESCE(firstname,'') AS Col1,
COALESCE(lastname,'') AS Col2, ROW_NUMBER() OVER(PARTITION BY firstname,lastname ORDER BY firstname,lastname) AS row_id
FROM #things
)
DELETE CTE WHERE row_id >1;
select * from #things
drop table #things
힌트 :'GROUP BY'를 확인하십시오. – jarlh
https://www.google.co.uk/search?q=sql+query+count+duplicates –
쿼리를 시작 했습니까? SQL을 작성할 수 있습니까? – samiles