+ 2

How to get only duplicated records

want duplicated record

27th Mar 2017, 4:17 AM
Bharat Kumar
Bharat Kumar - avatar
10 Antworten
+ 3
only duplicated or without duplicated??
27th Mar 2017, 4:35 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 3
select distinct sal from faculty not in( select sal from faculty);
27th Mar 2017, 4:36 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 3
ok try this.. i think somerhing gets wrong in my query
27th Mar 2017, 4:45 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 3
distinct gives you without duplicates suppose you have 4 rows which select by customer name,now if there are 2 duplicates then your query count no of without duplicates and give without duplicates rows
27th Mar 2017, 5:22 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 3
CREATE TABLE EMPLOYEE ( id INT IDENTITY(1,1) PRIMARY KEY NOT NULL, EMPNAME VARCHAR(100), SALARY DECIMAL ) SELECT * FROM EMPLOYEE INSERT INTO EMPLOYEE VALUES ( ‘Pawan’ , 100000 ) INSERT INTO EMPLOYEE VALUES ( ‘Pawan’ , 80000 ) INSERT INTO EMPLOYEE VALUES ( ‘Pawan’ , 40000 ) INSERT INTO EMPLOYEE VALUES ( ‘Rahul’ , 100000 ) INSERT INTO EMPLOYEE VALUES ( ‘Pawan’ , 100000 ) INSERT INTO EMPLOYEE VALUES ( ‘Gauri’ , 100000 ) INSERT INTO EMPLOYEE VALUES ( ‘Gauri’ , 100000 ) INSERT INTO EMPLOYEE VALUES ( ‘Rahul’ , 100000 ) INSERT INTO EMPLOYEE VALUES ( ‘Deepa’ , 100000 ) –Query to delete duplicate names in the above table SELECT name, salary, COUNT(*) FROM EMPLOYEE GROUP BY name, salary HAVING COUNT(*) > 1
27th Mar 2017, 5:24 AM
Akwin Lopez
Akwin Lopez - avatar
+ 3
yes this query work thanks @Akwin
27th Mar 2017, 5:25 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 1
only duplicated
27th Mar 2017, 4:44 AM
Bharat Kumar
Bharat Kumar - avatar
+ 1
select customer_name, count(distinct(customer_name)) where count(distinct(customer_name))>1;
27th Mar 2017, 5:05 AM
Bharat Kumar
Bharat Kumar - avatar
+ 1
only duplicated. . I think above query works, once excute and let me know. coz iam on mobile
27th Mar 2017, 5:06 AM
Bharat Kumar
Bharat Kumar - avatar
+ 1
CREATE TABLE EMPLOYEE ( id INT IDENTITY(1,1) PRIMARY KEY NOT NULL, EMPNAME VARCHAR(100), SALARY DECIMAL ) SELECT * FROM EMPLOYEE INSERT INTO EMPLOYEE VALUES ( ‘Pawan’ , 100000 ) INSERT INTO EMPLOYEE VALUES ( ‘Pawan’ , 80000 ) INSERT INTO EMPLOYEE VALUES ( ‘Pawan’ , 40000 ) INSERT INTO EMPLOYEE VALUES ( ‘Rahul’ , 100000 ) INSERT INTO EMPLOYEE VALUES ( ‘Pawan’ , 100000 ) INSERT INTO EMPLOYEE VALUES ( ‘Gauri’ , 100000 ) INSERT INTO EMPLOYEE VALUES ( ‘Gauri’ , 100000 ) INSERT INTO EMPLOYEE VALUES ( ‘Rahul’ , 100000 ) INSERT INTO EMPLOYEE VALUES ( ‘Deepa’ , 100000 ) –Query to find out the rows with duplicate names in the above table –Ouery will give u the name SELECT EmpName FROM EMPLOYEE GROUP BY EmpName HAVING COUNT(EmpName) > 1 –Query if you all the details SELECT id , EmpName , Salary FROM Employee WHERE EmpName IN (SELECT EmpName FROM EMPLOYEE GROUP BY EmpName HAVING COUNT(EmpName) > 1) Try this too...
27th Mar 2017, 6:11 AM
Akwin Lopez
Akwin Lopez - avatar