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.
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.
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.
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