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 |
|
akdom
Starting Member
1 Post |
Posted - 2009-05-29 : 04:28:02
|
| ID VALUE1 VALUE2001 1000 7777002 9999 7777003 7777 3000004 9999 4000005 6000 9999// I need to find the rows that have duplicates BOTH in VALUE1 and VALUE2. Could anyone tell me what the correct SQL statement should be?so the output should be like:duplicate FOUND ---> 7777ID VALUE1 VALUE2001 1000 7777002 9999 7777003 7777 3000duplicate FOUND ---> 9999ID VALUE1 VALUE2002 9999 7777004 9999 4000005 6000 9999 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-05-29 : 04:35:51
|
[code]SELECT ValueFROM ( SELECT DISTINCT Value1 AS Value FROM Table UNION ALL SELECT DISTINCT Value2 FROM Table ) AS dGROUP BY ValueHAVING COUNT(*) > 1[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
Dev@nlkss
134 Posts |
Posted - 2009-05-29 : 04:44:58
|
| select * from <Table>where case when v1 in(select distinct v2 from <Table>) then 1 when v2 in(select distinct v1 from <Table>) then 1 else 0 end=1$atya.Love All Serve All. |
 |
|
|
|
|
|