August 20, 2010 at 1:41 am
Is there a question here?
August 20, 2010 at 2:05 am
DECLARE @test-2 TABLE (a int, b int)
insert into @test-2 values (1,2)
insert into @test-2 values (2,1)
insert into @test-2 values (3,1)
insert into @test-2 values (4,1)
insert into @test-2 values (1,4)
This is my table and rows, now i want to the distinct value from this table. Eg col a value some time is repeated in col b and vice versa.
set like this
1,2
2,1
from this i want only one output, either 1,2 or 2,1 not both?
August 20, 2010 at 2:17 am
Something like this?
DECLARE @test TABLE (a int, b int)
insert into @test values (1,2)
insert into @test values (2,1)
insert into @test values (3,1)
insert into @test values (4,1)
insert into @test values (1,4)
insert into @test values (2,2)
SELECT a, b FROM @test
EXCEPT (
SELECT t1.a, t1.b FROM @test t1 JOIN @test t2
on t1.a = t2.b and t1.b = t2.a
WHERE t1.a > t1.b
)
John
August 20, 2010 at 3:57 am
Thansk John. It works fine
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply