Here are a couple of ways (PS it's easier if you post your data in a consumable format):--Sample Data
DECLARE @Foo TABLE (Plant CHAR(1), Plant2 CHAR(1))
INSERT @Foo
VALUES
('a', 'b'),
('b', 'a'),
('a', 'd'),
('s', 'y'),
('a', 'b')
-- Using MIN/MAX with VALUES clause
SELECT
P1 AS Plant,
P2 AS Plant2,
COUNT(*) AS [Sum]
FROM
(
SELECT
(SELECT MIN(P) FROM (VALUES (Plant), (Plant2)) AS Foo(P)) AS P1,
(SELECT MAX(P) FROM (VALUES (Plant), (Plant2)) AS Foo(P)) AS P2
FROM
@Foo AS F
) AS T
GROUP BY
P1, P2
--Using Case expression
SELECT
CASE WHEN Plant <= Plant2 THEN Plant ELSE Plant2 END AS Plant,
CASE WHEN Plant > Plant2 THEN Plant ELSE Plant2 END AS Plant2,
COUNT(*) AS [Sum]
FROM @Foo
GROUP BY
CASE WHEN Plant <= Plant2 THEN Plant ELSE Plant2 END,
CASE WHEN Plant > Plant2 THEN Plant ELSE Plant2 END