Suppose we have a table named EmployeeDeptInfo which have the column Employeid and Departmentid. The query for creating this table is given below:-
Employeeid contains the Id of the employee and Departmentid contains the Id of the department to which he/she is belonged. This table do not have any primary key defined on it and also it doesnt have any unique key constraint defined on any column.
Suppose the table contains the following data
2 2
In this table, entries for the employee having employeeid 2 & 3 are get repeated.In this example the data in the table is not much for the example point of view but in real time scenario it can be billions of rows and duplication of rows can be a very big concern. Therefore it is necessary to find out the duplicate rows in the table. We can use the Having Clause to find out the duplicate rows:-
Query for finding out the duplicate rows in the table:-
This query will give us the following results:-
We can also find out that how many times a record is repeated in the table. For example, The following query gives us the result of how many times a given record is repeated
This query will give us the following results
2 2 3
Here NoOfRepeat shows the number of times the records are duplicated in the table
This article shows that we can find the duplicate records with the help of the Group By and Having Clause.
excellent!! have been looking for this!!
Thanks:-)……… looking forward for your more feedback.
thans simple and superb mamoooooo
Thanks .:-)
its nice, But i have a doubt is there any procedure to eliminate duplicate records with out using distinct key word.
Yes there is a way to delete duplicate records without using the distinct keyword
Here is the Query
with i as (select *,row_number() over (partition by Dep_ID order by DEP_ID ) as rank from emp)
delete from i where rank>1
Pingback: hop over to this website
Pingback: agencia de viajes en managua
Pingback: p10496#forum.krajowy.biz
Pingback: ONLINE TRAINING BUILD INTERNET BUSINESS MAKE MONEY
Pingback: Sex doll movie—- Lars and the Real Girl
Pingback: redirected here
Pingback: new website
Pingback: HyphenMax Ecommerce Refreshed
Pingback: Jadwal Piala Eropa
Pingback: click here for info
Pingback: a lot
Pingback: http://thetoptrainticketbiz.strikingly.com/blog/getting-cheap-train-tickets-in-the-uk
Pingback: https://getthebesttraintickets.weebly.com/blog/tips-to-find-cheap-train-tickets
Pingback: aimimchems
Pingback: vao w88
Pingback: didi
Pingback: laser hair removal
Pingback: เล่นพนันออนไลน์
Pingback: botox
Pingback: ทางเข้าUFABET
Pingback: 메이저안전놀이터
Pingback: refresher on film
Pingback: http://apartamentynaibizie.pl/gazeta-wyborcza-kielce-163-2016-2563.php
Pingback: QE4! Stock Market Economy Gold Silver and Crazy News Important Update
Pingback: movies
Pingback: Pre-Market Stocks Gold Silver Update Today New Futures Exchange for Gold
Pingback: شركات التنظيف بالرياض