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 2000 Forums
 SQL Server Development (2000)
 Stored Procedures

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-13 : 08:50:05
Bill writes "I have a table and when I do a simple "Select * From TableA" it gives me back

1
1
2
3
4
5
6
6
7
7
7
8

How can I make it only give me back the records thate repeat like this.


1
1
6
6
7
7
7



Bill Chapin"

Nazim
A custom title

1408 Posts

Posted - 2002-03-13 : 09:11:57
select * from tablename
where id in (select id from
tablename
group by id
having count(*)>1)

HTH

--------------------------------------------------------------
Go to Top of Page

joldham
Wiseass Yak Posting Master

300 Posts

Posted - 2002-03-13 : 09:13:44
Try the following:

SELECT *
FROM A
GROUP BY columna HAVING COUNT(columna) > 1

Jeremy


Go to Top of Page

Nazim
A custom title

1408 Posts

Posted - 2002-03-13 : 09:18:25
Bill if you have more columns other then id you can use the query i have written ,otherwise Jeremy's is fine.


--------------------------------------------------------------
Go to Top of Page
   

- Advertisement -