You are on page 1of 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