+ 2
How to get only duplicated records
want duplicated record
10 Antworten
+ 3
only duplicated or without duplicated??
+ 3
select distinct sal from faculty not in( select sal from faculty);
+ 3
ok try this..
i think somerhing gets wrong in my query
+ 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
+ 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
+ 3
yes this query work thanks @Akwin
+ 1
only duplicated
+ 1
select customer_name, count(distinct(customer_name))
where count(distinct(customer_name))>1;
+ 1
only duplicated. . I think above query works, once excute and let me know. coz iam on mobile
+ 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...