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.
| Author |
Topic |
|
gurusamy.senthil
Yak Posting Veteran
65 Posts |
Posted - 2007-02-08 : 02:44:27
|
| Hello Everyone,Consider the below tableDocNbr Cheques00001 10101000002 10101000002 10202000003 10303000004 10303000004 10404000005 105050I just need the single select to result the docnbr which is repeating the values. In the above case I want my result like below where the DocNbr 00002 and 00004 repeated their values.DocNbr Cheques00002 10101000002 10202000004 10303000004 104040Thanks in advance,Senthil .GNote: I do not consider if the cheque contain repeated values |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-02-08 : 02:48:34
|
[code]select *from yourtable tinner join ( select DocNbr from yourtable group by DocNbr having count(*) > 1 ) r on t.DocNbr = r.DocNbr[/code] KH |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-08 : 02:49:04
|
| select t1.* from table1 as t1 where t1.docnbr in (select t2.docnbr from table1 as t2 group by t2.docnbr having count(*) > 1)select t1.*from table1 as t1inner join (select docnbr from table1 group by docnbr having count(*) > 1) as x on x.docnbr = t1.docnbrPeter LarssonHelsingborg, Sweden |
 |
|
|
gurusamy.senthil
Yak Posting Veteran
65 Posts |
Posted - 2007-02-08 : 03:26:58
|
| That works fine, Thank you khtan and peso. |
 |
|
|
|
|
|