我想从路线中选择机场,事情是机场对显示2次:
我想只显示一半(例如只有BZK DME而不是BZK DME和DME BZK)
SELECT
departure_airport,
arrival_airport,
departure_city,
arrival_city,
count (departure_airport) as sum
FROM
routes
GROUP BY
departure_airport,
arrival_airport,
departure_city,
arrival_city
HAVING
count (departure_airport) > 2;
答案 0 :(得分:1)
只需使用[
{ id: 'abc' },
{ id: 'ghi' },
{ id: 'def' }
]
:
<
这假设所有路线都有精确对。这是你的问题所暗示的。
答案 1 :(得分:0)
您可以使用Row_Number()选择到达机场和出发机场的特定组合
(select departure_airport, arrival_airport, departure_city, arrival_city,
count (departure_airport) as sum,row_number()(order by departure_airport,arrival_airport) as row
from routes
group by departure_airport, arrival_airport, departure_city, arrival_city
having count (departure_airport) > 2
)where row=1