What is the Query to print out the individual total number of
duplicate row in sql.
Answers were Sorted based on User's Feedback
Answer / girija.112
ANS:
SELECT department_id,COUNT(department_id) AS "Occurrences"
FROM departments
GROUP BY department_id
HAVING ( COUNT(department_id) > 1 )
DEPARTMENT_ID Occurrences
------------- -----------
80 2
60 3
--In my 'departments' table , i have not assigned department_id column as a "primary key / unique key"
| Is This Answer Correct ? | 28 Yes | 3 No |
Answer / raveendran
SQL>select * from a;
A B
---- -------------------------
1 Name
ABC
BCA
fdhgjdshfj
3 Name
ABC
BCA
fdhgjdshfj
2 Name
ABC
BCA
fdhgjdshfj
4 Name
ABC
BCA
fdhgjdshfj
5 asd
A B
---- -------------------------
asd
asd
asdd
6 asd
asd
7 asd asd
8 asd asd
sql>select count(b),b from a group by b having count(b)>=1;
T(B) B
---- -------------------------
4 Name
ABC
BCA
fdhgjdshfj
1 asd
asd
1 asd
asd
asd
asdd
2 asd asd
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / vivek ghorad
SELECT * FROM emp WHERE ROWID NOT IN(SELECT MIN(ROWID)FROM
emp GROUP BY empno,fname,dept);
| Is This Answer Correct ? | 3 Yes | 6 No |
Answer / ashish bakal
select count(deptno), deptno from emp where rowid not in
(select min(rowid) from emp group by deptno) group by
deptno;
| Is This Answer Correct ? | 0 Yes | 3 No |
What are the usage of SAVEPOINTS?
how to run 'mysql' commands from a batch file? : Sql dba
Does sql full backup truncate logs?
How many aggregate functions are available there in sql?
What is difference between Procedures and Functions ?
Why do we need pl sql?
What are the different types of constraints?
How long will it take to learn pl sql?
what tools available for managing mysql server? : Sql dba
What is the limitation on the block size of pl/sql?
What is nvarchar in sql?
What is sql in java?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)