0% found this document useful (0 votes)
106 views1 page

Latest Capgemeni Question

The document discusses how to retrieve unique records from a table or set of tables in SQL. It provides answers for how to get unique records from a single table using DISTINCT, count unique rows using a subquery with DISTINCT, and get unique records across tables by joining on fields and excluding duplicate records.

Uploaded by

Rohit Khurana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views1 page

Latest Capgemeni Question

The document discusses how to retrieve unique records from a table or set of tables in SQL. It provides answers for how to get unique records from a single table using DISTINCT, count unique rows using a subquery with DISTINCT, and get unique records across tables by joining on fields and excluding duplicate records.

Uploaded by

Rohit Khurana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

SQL:1.

How

to get the unique records (without duplicate) from the table?

2. How

to get the unique records from the set of tables?

3. How

to calculate the number of unique rows from a table?

ANS: 1)SELECT COUNT(*) FROM (SELECT DISTINCT * FROM Emp) Emp


2)SELECT COUNT(*) FROM (SELECT DISTINCT SAL FROM Emp) Emp >>>SELECT A.ENAME,A.HIREDATE FROM EMP A,EMP B WHERE A.HIREDATE=B.HIREDATE AND A.EMPNO<>B.EMPNO >>>SELECT A.HIREDATE,COUNT(A.HIREDATE) FROM EMP A,EMP B WHERE A.HIREDATE=B.HIREDATE AND A.EMPNO<>B.EMPNO GROUP BY A.HIREDATE

You might also like