Given the following schema:
id departure arrival
0 BOS LAX
1 SFO SEA
2 MIA LAX
3 RDU BOS
4 JFK DEN
5 LAX SEA
I need to count the total occurrences of each airport. For example, BOS should be 2 (one departure and one arrival).
I'm able to do this with two separate queries:
SELECT departure, COUNT(*) FROM legs
GROUP BY departure ORDER BY COUNT(departure) DESC
and
SELECT arrival, COUNT(*) FROM legs
GROUP BY arrival ORDER BY COUNT(arrival) DESC
but I haven't been able to figure out or find a way to do it in one query. I'd like to have something like the following:
airport count
BOS 2
LAX 2
SEA 2
JFK 1