You are given two tables, buses and passengers, with the following structure: create table buses ( id integer primary ke

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

You are given two tables, buses and passengers, with the following structure: create table buses ( id integer primary ke

Post by answerhappygod »

You Are Given Two Tables Buses And Passengers With The Following Structure Create Table Buses Id Integer Primary Ke 1
You Are Given Two Tables Buses And Passengers With The Following Structure Create Table Buses Id Integer Primary Ke 1 (81.32 KiB) Viewed 117 times
You Are Given Two Tables Buses And Passengers With The Following Structure Create Table Buses Id Integer Primary Ke 2
You Are Given Two Tables Buses And Passengers With The Following Structure Create Table Buses Id Integer Primary Ke 2 (62.58 KiB) Viewed 117 times
You Are Given Two Tables Buses And Passengers With The Following Structure Create Table Buses Id Integer Primary Ke 3
You Are Given Two Tables Buses And Passengers With The Following Structure Create Table Buses Id Integer Primary Ke 3 (39.1 KiB) Viewed 117 times
You Are Given Two Tables Buses And Passengers With The Following Structure Create Table Buses Id Integer Primary Ke 4
You Are Given Two Tables Buses And Passengers With The Following Structure Create Table Buses Id Integer Primary Ke 4 (48.74 KiB) Viewed 117 times
You are given two tables, buses and passengers, with the following structure: create table buses ( id integer primary key, origin varchar not null, destination varchar not null, time varchar not null, unique (origin, destination, time) ); create table passengers ( id integer primary key, origin varchar not null, destination varchar not null, time varchar not null ); Each row of table buses contains information about a single bus's origin (origin), destination (destination) and time of departure (time). Each rov of table passengers describes a single passenger and contains information about the station they're traveling from (origin), the station they're traveling to (destination) and the time they will arrive at the departure station (time). Passengers will board the earliest possible bus that travels directly their desired destination. Passengers can still board a bus if it departs in the same minute that they arrive at the station. All passengers who are still at the station at 23:59 and don't board any of the 23:59 buses will leave the platform without boarding any bus. You can assume that no two buses with the same origin and destination
depart at the same time. Write an SQL query that, for each bus, returns the number of passengers boarding it. For each bus you should provide its id (id) and the number of passengers on board (passengers_on_board). Rows should be ordered by the id column (in ascending order). Time is represented as a string in the format HH:MM. Examples: 1. Given tables: buses: id origin | destination | time 10 Warsaw Berlin 10:55 20 Berlin | Paris 06:20 14:00 21 | Berlin | Paris Berlin Paris 22 21:40 30 Paris | Madrid 13:30
passengers: id | origin 1 2 10 | Warsaw 11 | Warsaw 40 | Berlin 41 | Berlin Berlin 42 Paris Paris 43 | Berlin 44 | Berlin id your query should return: ----- 10 20 21 22 1 30 | 1 | destination | time 0 1 passengers_on_board W3 Madrid Madrid Paris Berlin Paris Paris Paris Paris Paris 13:30 13:31 10:00 22:31 06:15 06:50 07:12 12:03 20:00
2. Given tables: buses: id | origin | destination | time Munich Rome Munich | Rome Rome 100 200 300 | Munich passengers: id | origin | destination | time 1 Munich | Rome 2 | Munich | Rome Munich | Rome 3 4 | Munich | Rome 5 | Munich Rome your query should return: id 100 | 5 200 0 300 0 13:00 15:30 20:00 passengers_on_board 10:01 11:30 11:30 12:03 13:00
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply