EasySQL

Filter Flights by Price Range

SQLDatabases

Write a SQL query that returns all flights with a price **between $80 and
$250 inclusive**, showing the route and price, ordered by price ascending.

Table: `flights`

idroutepriceairline
1NYC-LAX250United
2NYC-CHI120Delta
3LAX-SFO80Southwest
4CHI-MIA320American
5SFO-SEA90Alaska
6NYC-BOS55JetBlue

Expected output (columns: route, price)

LAX-SFO|80
SFO-SEA|90
NYC-CHI|120
NYC-LAX|250

BETWEEN a AND b is inclusive on both ends — equivalent to >= a AND <= b.

Sample tests

Test #14 of 6 flights fall within the range
Input: "CREATE TABLE flights (id INTEGER, route TEXT, price INTEGER, airline TEXT);\nINSERT INTO flights VALUES\n (1, 'NYC-LAX', 250, 'United'),\n (2, 'NYC-CHI', 120, 'Delta'),\n (3, 'LAX-SFO', 80, 'Southwest'),\n (4, 'CHI-MIA', 320, 'American'),\n (5, 'SFO-SEA', 90, 'Alaska'),\n (6, 'NYC-BOS', 55, 'JetBlue');"
Output: "LAX-SFO|80\nSFO-SEA|90\nNYC-CHI|120\nNYC-LAX|250"