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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 displaying repeating rows

Author  Topic 

DMarmolejos
Yak Posting Veteran

65 Posts

Posted - 2008-10-29 : 11:53:15
How can I display only the rows that are repeating?

SELECT DocNum, BarCode
FROM Table1
WHERE BarCode = BarCode * 1


This is what I had, but doesnt work. Is there a way that I can just select all rows in BarCode where there is a repeat?

Any help is appreciated, thanks.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-29 : 11:55:45
[code]SELECT t1.DocNum, t1.BarCode
FROM Table1 t1
JOIN (SELECT BarCode
FROM Table1
GROUP BY BarCOde
HAVING COUNT(*) >1)t2
ON t1.BarCode=t2.BarCode[/code]
Go to Top of Page

DMarmolejos
Yak Posting Veteran

65 Posts

Posted - 2008-10-29 : 15:32:57
thanks alot bro! solved my problem
Go to Top of Page
   

- Advertisement -