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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-01-31 : 09:01:52
|
| Dave writes "have a table called extract file and I need to a duplicate query on id field but I only want duplicates in different states not in the same states.I want to see only duplicates in different duplicates of id in various statesThis is what the current code that I am using looks likeSELECT TOP 100 PERCENT State, [Debt Number], ID, [Last Name], [First Name]FROM dadedeji.[Extract File]WHERE (ID IN(SELECT [ID]FROM dadedeji.[Extract File] AS TmpGROUP BY [ID]HAVING COUNT(*) > 1))AND (State<>State)ORDER BY SSN, State" |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-01-31 : 11:10:48
|
| select *from tbl t1where exists (select * from tbl t2 where t2.id = t1.id and t2.state <> t1.state)select idfrom tblgroup by idhaving count(distinct state) > 1==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|