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
 Transact-SQL (2000)
 re: duplicates in sql statement

Author  Topic 

uplate
Starting Member

10 Posts

Posted - 2004-11-01 : 01:06:33
Hello all! Thanks in advance for your help.
I hope someone can offer some help. I am a very NEWBIE.

I have a table with 2 fields.
Field 1 called t1, Field 2 called t2
table look like this:
FIELDS t1 T2
DATA : 1 TEST1
1 TTTT1
2 OK
3 OK
4 hhh
4 uuu
I NEED TO PULL OUT THE DATA WHEN field T1 IS DUPLICATED BUT field T2 IS DIFFERENT?
SO OUPUT looks like
1-- TEST1
1-- TTTT1
4-- hhh
4-- uuu
I hope there is an easy sql statement to handle this.
ANY HELP WOULD BE GREAT!
THANKS
UPLATE

B0g
Starting Member

19 Posts

Posted - 2004-11-01 : 02:46:39
SELECT *
FROM Table
WHERE t1 IN (SELECT t1
FROM Table
GROUP BY t1
HAVING COUNT(t1) > 1 )
Go to Top of Page
   

- Advertisement -