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 |
KabirPatel
Yak Posting Veteran
54 Posts |
Posted - 2007-09-20 : 10:23:40
|
I have a table as follows:Group DocName Language URI----------------------------------------------------------GroupA Bob En http://bogusGroupA Bob En http://bogusGroupA Fred En http://anotherGroupA Fred En http://badGroupB Susi En http://testGroupB Susi En http://testI need a listing of all identical DocNames within each Group that has different URI values without using a cursor.i.e. for the above data I would want the following records to come out:Group DocName Language URI----------------------------------------------------------GroupA Fred En http://anotherGroupA Fred En http://badThanks,Kabir |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2007-09-20 : 10:44:34
|
SELECT b.*FROM (select [group],DocName,count(*) from yourtable group by [group],DocName having count(*) > 1 ) aINNER JOIN yourtable bON a.group = b.groupand a.docname = b.docnameJim |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-09-21 : 05:08:11
|
quote: Originally posted by jimf SELECT b.*FROM (select [group],DocName,count(*) as counts from yourtable group by [group],DocName having count( DISTINCT URI) > 1 ) aINNER JOIN yourtable bON a.group = b.groupand a.docname = b.docnameJim
MadhivananFailing to plan is Planning to fail |
 |
|
KabirPatel
Yak Posting Veteran
54 Posts |
Posted - 2007-09-21 : 09:01:47
|
Thanks. That works a treat. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-09-21 : 09:23:09
|
Note that most of the time, you can do the things without using a cursor as explainedMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|