runtime
07 / 139

task DISTINCT · warm-up

Borough and service-zone combinations

Return each distinct pair of borough_id and service_zone found in zones.

what to return

Columns
borough_idservice_zone in this order
Rows
10 rows · any order
Skill
Return each distinct combination once. Refresher: Unique values with DISTINCT →

expected result

Your query should return exactly these columns and values. Run it and compare.

expected result10 rows · any order
borough_idservice_zone
1EWR
2Boro Zone
3Boro Zone

first 3 of 10 rows

data you can query

Mobility dataset: the first 6 rows of each table. Under each column name: the kind of value it holds, and which table it links to. Your queries run on all rows.

zones5 columns · 265 rows
zone_idnumber · unique idzone_nametextborough_idnumber · links to boroughsservice_zonetextis_airportnumber
1Newark Airport1EWR1
2Jamaica Bay2Boro Zone0
3Allerton/Pelham Gardens3Boro Zone0
4Alphabet City4Yellow Zone0
5Arden Heights5Boro Zone0
6Arrochar/Fort Wadsworth5Boro Zone0
zone_idnumber · unique id
1
zone_nametext
Newark Airport
borough_idnumber · links to boroughs
1
service_zonetext
EWR
is_airportnumber
1
zone_idnumber · unique id
2
zone_nametext
Jamaica Bay
borough_idnumber · links to boroughs
2
service_zonetext
Boro Zone
is_airportnumber
0
zone_idnumber · unique id
3
zone_nametext
Allerton/Pelham Gardens
borough_idnumber · links to boroughs
3
service_zonetext
Boro Zone
is_airportnumber
0
zone_idnumber · unique id
4
zone_nametext
Alphabet City
borough_idnumber · links to boroughs
4
service_zonetext
Yellow Zone
is_airportnumber
0
zone_idnumber · unique id
5
zone_nametext
Arden Heights
borough_idnumber · links to boroughs
5
service_zonetext
Boro Zone
is_airportnumber
0
zone_idnumber · unique id
6
zone_nametext
Arrochar/Fort Wadsworth
borough_idnumber · links to boroughs
5
service_zonetext
Boro Zone
is_airportnumber
0

first 6 of 265 rows · your queries use all of them

solution.sql
 

Hints and the answer are always available. Using them counts the question as solved with help.

Borough and service-zone combinations — SQL practice · Runtime