Removing similar data

  • create table dbo.tableinfo

    (

    list1 varchar(10),

    list2 varchar(10),

    Num int

    )

    insert into dbo.tableinfo values

    ('A','A',5),

    ('A','B',2),

    ('A','C',7),

    ('A','D',2),

    ('B','A',2),

    ('B','B',4),

    ('C','A',7),

    ('C','B',6),

    ('C','C',7),

    ('C','D',8),

    ('C','E',3),

    ('D','A',2),

    ('D','B',5),

    ('D','C',8)

    Expected out put is as following:

    A B 2

    A C 7

    A D 2

    C B 6

    C D 8

    C E 3

    D B 5

    Condition1, is do not display same same in list1 and list2, eg A A 5

    condition2, is do not display "A B 2" and "B A 2" twice, show any one only once.

  • Duplicate post, add reply to http://www.sqlservercentral.com/Forums/Topic1467913-391-1.aspx

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply