• Lengthy, but there might not be a better alternative without fixing the data.

    CREATE TABLE SampleData(
      col1 varchar(10),
      col2 varchar(10),
      col3 int
    );
    INSERT INTO SampleData
    VALUES
      ('A', 'B', 10),
      ('B', 'A', 5 ),
      ('C', 'D', 8 );

    SELECT CASE WHEN col1 <= col2 THEN col1 ELSE col2 END AS col1,
       CASE WHEN col1 <= col2 THEN col2 ELSE col1 END AS col2,
       SUM( col3) AS col3
    FROM SampleData
    GROUP BY CASE WHEN col1 <= col2 THEN col1 ELSE col2 END,
       CASE WHEN col1 <= col2 THEN col2 ELSE col1 END;

    GO
    DROP TABLE SampleData

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2