What is the Query to print out the individual total number of
duplicate row in sql.

Answers were Sorted based on User's Feedback



What is the Query to print out the individual total number of duplicate row in sql...

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

What is the Query to print out the individual total number of duplicate row in sql...

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

What is the Query to print out the individual total number of duplicate row in sql...

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

What is the Query to print out the individual total number of duplicate row in sql...

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 is the Query to print out the individual total number of duplicate row in sql...

Answer / ahmad

SELECT DISTINCT(ENAME) FROM EMP;

Is This Answer Correct ?    1 Yes 24 No

Post New Answer

More SQL PLSQL Interview Questions

How do you optimize SQL queries ?

6 Answers   CarrizalSoft Technologies, Infosys, Oracle,


What are sql constraints?

0 Answers  


What are the types of join and explain each?

0 Answers  


a. Can you delete data from a View. b. If Yes, can you delete it if there are multiple tables c. If No, can you delete if there is single source table which is joining.

4 Answers   CGI, IBM,


Under what condition it is possible to have a page level lock and row lock at the same time for a query? : Transact sql

0 Answers  






How to update salary of employees department wise?

6 Answers  


when MSQL8.0 is in market

0 Answers  


How to get list of all tables from a database?

0 Answers  


What do you mean by stored procedures?

0 Answers  


How many unique keys can a table have?

0 Answers  


What are two statement types in sql?

0 Answers  


Can a view be updated/inserted/deleted?If Yes under what conditions?

3 Answers  


Categories