Q:

How to check for mutiple rows with same data?

Can anyone advise how do I check multiple rows with same data?
E.g. 
I have 2 rows with following values:
Cola         Colb  Colc
TYPE_APPLE   123   abc
Colb         Colb  Colc
TYPE_APPLE   123   abc

I want to write an SQL query which will not select data of multiple rows which contain the same data as above. How should I write the query? 

A:

DISTINCT will combine identical rows.  GROUP BY will combine them and allow you to know which ones had multiples using COUNT(*).  To meet your "not select data of multiple rows" requirement you will need to add a HAVING clause.  Your query will look something like this:
SELECT cola, colb, colc FROM T1 GROUP BY cola, colb, colc HAVING count(*) = 1;

SQL Fiddle Demonstration

A:

For the sake of completeness, I would add using ROW_NUMBER() OVER PARTITION BY method :
I will use the same fiddle written by Leigh Riffel.
CREATE TABLE T1 (Cola Varchar(20), Colb Varchar(10), Colc Varchar(10));

INSERT INTO T1 VALUES ('TYPE_APPLE','123','abc');
INSERT INTO T1 VALUES ('TYPE_ORANGE','456','def');
INSERT INTO T1 VALUES ('TYPE_APPLE','123','abc');
INSERT INTO T1 VALUES ('TYPE_ORANGE','123','abc');
INSERT INTO T1 VALUES ('TYPE_APPLE','567','abc');
INSERT INTO T1 VALUES ('TYPE_APPLE','123','xyz');

--- below will give you the table with just single rows - non duplicates
;WITH CTE AS 
( 
SELECT ROW_NUMBER() OVER 
(PARTITION BY [Cola], [Colb], [Colc] 
Order BY [Cola] desc, [Colb] desc, [Colc] desc ) 
AS RowNumber, 
[Cola], [Colb], [Colc]
FROM T1 tbl ) 
SELECT [Cola], [Colb], [Colc] FROM CTE where RowNumber = 1
GO

