Saturday, May 8, 2010

SQL Distinct Unique Records

0 comments

The Below Query will select all rows this will also include repetative or redundent rows i..e un necessary or duplicated rows  i.e. UNIQUE Records
SELECT WORKDEPT
FROM EMP
Distinct rows:
This is will extract all the rows but will remove the duplicated rows
1.SELECT DISTINCT WORKDEPT
FROM EMP
2.SELECT DISTINCT WORKDEPT, JOB
FROM EMP
Distinct Count
One person can send many feedack / comments against this post so count the unique no of person who posted their comments
                                 SELECT POSTED_BY,COUNT(DISTINCT COMMENTS)
                                 FROM FEEDBACK
                                 GROUP BY POSTED_BY 

0 comments: