A ride hailing company has their DB structured in 3 major tables as described in the...
Fantastic news! We've Found the answer you've been seeking!
Transcribed Image Text:
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. v Schema You are provided 3 tables: CITIES, USERS, and RIDES. CITIES Name Type Description id String The assigned ID to the city presented as 32 character UUID. name String The name of the city. USERS Name Type Description 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. v Sample Data Tables CITIES id name 1 Cooktown South Suzanne USERS id city_id email name 1 2 Robert Delgado robertdelgado@hotmail.com 2 Thomas Williams thomaswilliams@bradley.org 3 1 Michele Peterson michelepeterson@hotmail.com 4 1 Bill Wheeler billwheeler@gmail.com 1 David Lloyd davidlloyd@gmail.com 6. 1 Morgan Powers morganpowers@hansen.biz RIDES id user_id distance fare 1 1 21 200 55 6, 5. 30 230 4 2 16 125 2 11 110 30 285 7 18 170 8 1 50 2 4 40 10 1 10 90 11 11 95 12 16 140 13 3 24 220 14 17 160 15 2 23 205 16 3 11 90 17 50 18 3 19 180 19 22 205 20 6 60 Expected Output Thomas Williams 84 Michele Peterson 78 Morgan Powers 63 David L lovd 38 1 /* 2 Enter your query below. 3 Please append a semicolon ";" at the end of the query 4 */ 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. v Schema You are provided 3 tables: CITIES, USERS, and RIDES. CITIES Name Type Description id String The assigned ID to the city presented as 32 character UUID. name String The name of the city. USERS Name Type Description 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. v Sample Data Tables CITIES id name 1 Cooktown South Suzanne USERS id city_id email name 1 2 Robert Delgado robertdelgado@hotmail.com 2 Thomas Williams thomaswilliams@bradley.org 3 1 Michele Peterson michelepeterson@hotmail.com 4 1 Bill Wheeler billwheeler@gmail.com 1 David Lloyd davidlloyd@gmail.com 6. 1 Morgan Powers morganpowers@hansen.biz RIDES id user_id distance fare 1 1 21 200 55 6, 5. 30 230 4 2 16 125 2 11 110 30 285 7 18 170 8 1 50 2 4 40 10 1 10 90 11 11 95 12 16 140 13 3 24 220 14 17 160 15 2 23 205 16 3 11 90 17 50 18 3 19 180 19 22 205 20 6 60 Expected Output Thomas Williams 84 Michele Peterson 78 Morgan Powers 63 David L lovd 38 1 /* 2 Enter your query below. 3 Please append a semicolon ";" at the end of the query 4 */
Expert Answer:
Answer rating: 100% (QA)
SELECT TOP 100 USERSnameSUMRIDESdistance AS distancetraveled FROM USERS INNER JOIN RIDES ON RIDESuse... View the full answer
Related Book For
Database Systems Design Implementation and Management
ISBN: 978-1285196145
11th edition
Authors: Carlos Coronel, Steven Morris
Posted Date:
Students also viewed these programming questions
-
Show transcribed image text n? Starfax, Inc., manufactures a small part that is widely used in various electronic products such as home computers. Results for the first three years of operations were...
-
British Airways PLC plan to set aside investment funds now for replacing 34 of the airlines aging long-haul fleet of Boeing 747s and 767s which will be delivered 5 years from now. How much will the...
-
Show transcribed image text In the United States, private health insurance plans can be written as group or individual plans, or as indemnity or managed care plans. Comparing Private Insurance Plans...
-
On 28 April 2020, Mr Guna, CEO of Econ Engineering Malaysia, proposed to complete an abandoned boiler project that no one had dared to revive. He knew that the project was 60% complete before it was...
-
What is the difference among the terms fashion, a fashion, and in fashion?
-
Offspring of certain fruit flies may have yellow or ebony bodies and normal wings or short win Genetic theory predicts that these traits will appear in ratio 9:3:3:1 (9 yellow, normal: 3 yellow,...
-
Organizations have traditionally used employee time saved as the primary source of benefits to justify HRIS and other types of information system investments. Why can this be problematic? Give...
-
The following is an alphabetical list of the accounts of the Oliver Manufacturing Company as of December 31, 2007: Accounts payable .............Interest payable Accounts receivable...
-
The Olson Company reports a $ 1 1 6 , 0 0 0 figure that is labeled capital stock on its balance sheet. What information is being communicated?
-
1. Show how the sampling error calculations for the posttest measures were calculated. 2. If the CEO wanted to be sure that the estimates of awareness and positive image are within 2 percent of the...
-
In what circumstance individuals and companies are treated as a resident of Australia for tax purposes? Discuss based on the provisions of the Income Tax Assessment Act 1936 (Cth) and relevant common...
-
Marketing SPOTLIGHT SAMSUNG "Huh?" That would have been the reaction of most consumers when asked about Korean electronics giant Samsung (meaning "three stars") a decade ago. Indeed, the situation...
-
Product Life Cycle-Timbits Individual Homework Activity You have been tasked to re-position Timbits! Your strategy may include modifying the product, modifying the market an/or linking the product to...
-
Private Jets case study to include: 4 Facts - List 4 facts that you identify from the case study. Identify the 4 Areas of Marketing (Product, Price, Promotion and Distribution). 2 Problems - Identify...
-
Smith had no stock transactions in 2 0 2 1 , so the change in stockholders' equity for 2 0 2 1 was due to net income and dividends. If dividends were $ 5 0 , 0 0 0 , how much was Smith's net income...
-
Howarth Manufacturing Company purchased equipment on June 30, 2020, at a cost of $175,000. The residual value of the equipment was estimated to be $10,000 at the end of a five-year life. The...
-
Requirement 1. For each depreciation method, prepare a depreciation schedule showing asset cost, depreciation expense, accumulated depreciation, and asset book value for each year of the asset's...
-
A liquid flows upward through a valve situated in a vertical pipe. Calculate the differential pressure (kPa) between points A and B. The mean velocity of the flow is 4.1 m/s. The specific gravity of...
-
Should you create an index? If so, what would the index column(s) be, and why should you create that index?
-
How would you (graphically) identify each of the following ERM components in a Crows Foot model? a. An entity b. The cardinality (0, N) c. A weak relationship d. A strong relationship
-
Create the table that would result from applying a DIFFERENCE relational operator of your result from problem 29 to your result from problem 30.
-
Among your colleagues in class, identify a term or phrase italicized in this chapter that you think is the most significant from your reading. Absent team consensus, then just provide your...
-
What are the two key financial objectives in the management of a company? How can a focus on these objectives create ethical dilemmas?
-
What is the purpose of financial statements? Would you want to produce them even if they were not required, say, for entity tax reporting?
Study smarter with the SolutionInn App