2 つの列を含むテーブルがあります。
最初の 2 行では、列の値が逆になっています。1 つの STATION_1_I が別のレコード STATION_2_I に等しく、その STATION_2_I が STATION_1_I に等しいインスタンスごとに 1 つのレコードを選択するにはどうすればよいでしょうか。
select a,b from
(
select
(case when a<b then a else b end) as a,
(case when a>b then a else b end) as b
from (
select station_1_I as a, station_2_I as b from MyTable
union all
select station_2_I, station_1_I from MyTable
) having count(*)=2 group by a,b
) group by a,b