Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Getting rows with same data

Author  Topic 

Regy
Starting Member

1 Post

Posted - 2010-12-04 : 01:12:48
I have a table with five columns(Sl_No,Supplier_Name,Supplier_Id,PB_Date,PB_Amount) with 1923 rows of data.
In this table for some rows, Supplier_Name,Supplier_Id and PB_Date colums data are same.

I want to get those rows from that table.

Is there any way?

Sachin.Nand

2937 Posts

Posted - 2010-12-04 : 01:22:12
[code]
select Supplier_Name,Supplier_Id,PB_Date from yourtable
group by Supplier_Name,Supplier_Id,PB_Date
having count(*)>1
[/code]

PBUH

Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-12-04 : 02:25:31
Moreover If you want to get all the columns of those rows
which are duplicate for the group Supplier_Name,Supplier_Id,PB_Date


SELECT T.* FROM YourTable T
INNER JOIN
(
select Supplier_Name,Supplier_Id,PB_Date from yourtable
group by Supplier_Name,Supplier_Id,PB_Date
having count(*)>1
) A ON T.Supplier_Name = A.Supplier_Name AND T.Supplier_Id = A.Supplier_Id AND T.PB_Date = A.PB_Date


Vaibhav T

If I cant go back, I want to go fast...
Go to Top of Page
   

- Advertisement -