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)
 Compare Duplicate with a NULL

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-11 : 08:51:39
Gavin writes "I am trying to select all of the duplicate values out of a table like this:


field1       field2          field3          field4        field5
jason anderson 266985421 Florida NULL
Derek Lee 56898755 Louisiana 32
jason anderson 266985421 Florida NULL





the first and third are duplicate records but with the sql I have so far it doesn't reconize them as dupes becuase of the NULL.

SELECT field1, field2, field3, field4, field5
FROM table
WHERE ((([field1]) In
(SELECT [field1]
FROM [table] AS TMP
GROUP BY field1, field2, field3, field4, field5
HAVING Count(*)>1 And [field1] = [table].[field1] AND ......and field5 = table.field5 )))
ORDER BY field1,field2, .......field5

what do I do???????????????????"

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2002-04-11 : 08:51:39
Here's an article that discusses duplicates (http://www.sqlteam.com/item.asp?ItemID=3331). You might also look at the COALESCE function.
Go to Top of Page
   

- Advertisement -