我有一个包含两列的表。
在前两行中,列的值是相反的,我如何为每个实例选择一个记录,其中一个 STATION_1_I 等于另一个记录 STATION_2_I 并且它的 STATION_2_I 等于 STATION_1_I。
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