below i am showing how to get duplicate record from the table with number of the occurrence in that column
suppose that i have two table one is employee and other one have emp_details
employee table have the master data like employee id ,name and other info and emp_details table have secondary information like address and salary so now my question in this to find out the salary that have duplicate entry
so according to my table structure i have following data in employee table
Emp id
|
FirstName
|
Last Name
|
Emp code
|
Position
|
location
|
1
|
Neeraj
|
Upadhyay
|
GCS-1795
|
Software Developer
|
Noida
|
2
|
Akhilesh
|
Upadhyay
|
GCS-1796
|
Software Developer
|
Delhi
|
3
|
Ashish
|
Bhisht
|
GCS-1797
|
Software Developer
|
Sawai madhopur
|
1002
|
Akash
|
Srivastava
|
GCS-1798
|
Software Developer
|
Kota
|
1003
|
Dikhsa
|
Rawat
|
GCS-1799
|
Software Developer
|
Naguar
|
1004
|
Vaishali
|
Gupta
|
GCS-1800
|
Software Developer
|
Aligarh
|
now the data in emp_details table
Emp_id
|
Address
|
Salary
|
1
|
behind old laxman mandir bharatpur rajasthan
|
50000
|
2
|
WZ-85 Todapur New delhi
|
50000
|
3
|
kerapati mohalla bharatpur
|
40000
|
1002
|
A-154/A sector 63 noida
|
55000
|
1003
|
india habitat center lodhi road new delhi
|
35000
|
So now we find the duplicate salary in both the table
so we execute following code
select salary,count(*) as duplicate from Employee inner join emp_details
on Employee.EmployeeID=Emp_details.emp_id
group by salary
having (COUNT(*)>1)