AnalystPath

Divisive Hiking Trails

SQLMediumMid level~15 min

Problem

Hikers rate the difficulty of each trail from 1 to 5. A trail is 'divisive' when it has at least five votes, at least one vote of 4 or higher, and at least one vote of 2 or lower. The divisiveness is the share of extreme votes (a score of 2 or lower, or 4 or higher) out of all votes. Report only trails whose divisiveness is at least 0.6. Sort by divisiveness descending, then by trail name descending.

Tables

Example rows — the live problem includes the full dataset.

trails
trail_idtrail_nameparklength_km
1Cedar RidgeGlacier7.5
2Foxglen LoopGlacier3.2
3Iron PassCascade12
difficulty_votes
vote_idtrail_idvoterscore
11va5
21vb1
31vc5

Expected output

Your answer should return 2 rows with the columns trail_name, divisiveness.

Starter code (SQL)

SELECT *
FROM trails;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions