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)
 selecting not unique documents

Author  Topic 

bspama
Starting Member

8 Posts

Posted - 2002-11-12 : 10:28:31
i have two fields, field1 which is an integer and field2 which is text, how do i select all documents in a table that have duplicate values in the field2 or is not unique and sorted based on their corresponding field1 integer values? Thanks!

cat_jesus
Aged Yak Warrior

547 Posts

Posted - 2002-11-12 : 10:40:02
select t.field1, sl.field2
from (select field2 from table1 group by field2 having count(*) > 1) as sl
join table1 t on sl.field2 = t.fieldl2
order by t.field1

Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2002-11-12 : 10:40:15
quote:

i have two fields, field1 which is an integer and field2 which is text, how do i select all documents in a table that have duplicate values in the field2 or is not unique and sorted based on their corresponding field1 integer values? Thanks!





I could have sworn that you already asked that

http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=21502

Go to Top of Page

bspama
Starting Member

8 Posts

Posted - 2002-11-12 : 10:44:51
Yup, but i forgot to ask how to sort it by the integer field that is why i decided to post it again and add that bit. Thanks to those who replied.

Go to Top of Page
   

- Advertisement -