A ride-hailing company has their DB structured in 3 major tables as described in the SCHEMA section below. Write a query

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

A ride-hailing company has their DB structured in 3 major tables as described in the SCHEMA section below. Write a query

Post by answerhappygod »

A ride-hailing company has their DB structured in 3 major tablesas described in the SCHEMA section below.Write a query to fetch the top 100 users who traveled the mostdistance using the service. The output should be struusers.name distance_traveledSort the output by distance traveled in descending order, then bythe user name in ascending order. Show only the top 100users,ignoring the ties at the last position.Note: There could be multiple users with the same name but theywill have different IDs.
A Ride Hailing Company Has Their Db Structured In 3 Major Tables As Described In The Schema Section Below Write A Query 1
A Ride Hailing Company Has Their Db Structured In 3 Major Tables As Described In The Schema Section Below Write A Query 1 (136.29 KiB) Viewed 34 times
A Ride Hailing Company Has Their Db Structured In 3 Major Tables As Described In The Schema Section Below Write A Query 2
A Ride Hailing Company Has Their Db Structured In 3 Major Tables As Described In The Schema Section Below Write A Query 2 (51.56 KiB) Viewed 34 times
A Ride Hailing Company Has Their Db Structured In 3 Major Tables As Described In The Schema Section Below Write A Query 3
A Ride Hailing Company Has Their Db Structured In 3 Major Tables As Described In The Schema Section Below Write A Query 3 (81.11 KiB) Viewed 34 times
A Ride Hailing Company Has Their Db Structured In 3 Major Tables As Described In The Schema Section Below Write A Query 4
A Ride Hailing Company Has Their Db Structured In 3 Major Tables As Described In The Schema Section Below Write A Query 4 (39.82 KiB) Viewed 34 times
(BETA Can't read the text? Switch theme 1. Maximum Distance A ride hailing company has their DB structured in 3 major tables as described in the SCHEMA section below. Write a query to fetch the top 100 users who traveled the most distance using the service. The output should be structured as: users.name distance_traveled Sort the output by distance traveled in descending order, then by the user name in ascending order. Show only the top 100 users, ignoring the ties at the last position. Note: There could be multiple users with the same name but they will have different IDs. ▼ Schema You are provided 3 tables: CITIES, USERS, and RIDES. Name Type id CITIES Description String The assigned ID to the city presented as 32 character UUID. name String The name of the city. USERS Name Type id String The assigned ID to the user presented as 32 character UUID. city_id String The id of the city in which this user resides. name String The name of the user. email String The email of the user. Description RIDES
id user_id distance fare 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 - 3 2 2 2 6 3 1 - 2 - 1 6 5 сл 3 6 2 3 6 3 5 RIDES 4 21 6 30 16 11 30 18 6 4 10 11 16 24 17 23 11 5 19 22 6 200 55 230 125 110 285 170 50 40 90 95 140 220 160 205 90 50 180 205 60
Sample Data Tables id 1 1 2 South Suzanne 2 id city_id 3 4 5 6 1 2 CITIES 3 4 Cooktown 5 2 2 1 name 1 1 1 1 id user_id distance fare 3 2 2 2 name Robert Delgado Thomas Williams Bill Wheeler [email protected] [email protected] Michele Peterson [email protected] [email protected] [email protected] [email protected] RIDES David Lloyd Morgan Powers 21 USERS 6 30 16 11 200 55 230 125 email 110
19 20 5 4 Expected Output 22 6 Thomas Williams 84 Michele Peterson 78 Morgan Powers 63 David Lloyd 38 Robert Delgado 37 Bill Wheeler 6 205 60
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply