Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Tools View sQL Advanced SQL 1970 aud 24-4-90 26-4-113 1971 volkswagen 4-43 1971 opel 1971 vokswagen 27-40 1972 vokswapen 23-454 1972 vokswagen22-4-76 1973 vokswagen 264-46

image text in transcribed
image text in transcribed
image text in transcribed
Tools View sQL Advanced SQL 1970 aud 24-4-90 26-4-113 1971 volkswagen 4-43 1971 opel 1971 vokswagen 27-40 1972 vokswapen 23-454 1972 vokswagen22-4-76 1973 vokswagen 264-46 counries.continent-car-makers.country, car-makers.id model details maker, model _details model : car_names.id car_details.id 39 rows returned 4. Provide a breakdown of the market share of each of the car manufacturers using a percentage. (HINT: total number of cars manufactured by a maker /total num- ber of cars produced 100) You need to know the total number of cars produced by each maker and the total number of cars produced overall. Order the results by market share in descending order. Display the model name with the first letter capitalized BONUS- if the MPG is null, display X in its place +3 2. Provide a list of models that have an average MPG for their cars that is less than the overall average for all cars. Display the average MGP for each model, the overall aver age for all models, and then the difference. Exclude the nulls from your calculations. Order by Model. 13.05 11.82 7.88 7.14 6 90 6.40 Ford Chevrolet Plymouth 2351 433 car makers in Germany. Use nested subqueries to mini- mize the number of joins that you will need. (Use a mini- mum of 2 nested queries). Display the out year and the model as one field called Model and display the mpe, eyl inders, and horsepower as one field, each column sepa rated by called Specs. Order by year 2351 2351 33 625 Volkswagen 5.7 Datsun 235132 5 67 4.19 3 94 Pontiac 3. Provide a list of the cars that have null MPG. In the list, display the model, description, MPG, and a count of all the cars that don't have a null MPG BONUS- modify the query to confirm that the percent ages all add up to 100+ 2 pts Tools View and cn.country c.countryid group by c.countryid 100.00 in 0.00 seconds HINT: you will need to use a subquery in the from clause, a subquery in the where clause, and one of them will be correlated 5. For each country, list the country id, country name, con- tinent name and the number of cars produced by each country. Order the results by car count in descending order in 0.01 The following is a nested aggregate function that will return the maximum number of cars provided by a single country select max (count (c2.countryid)) from car names en2, countries c2, car makers em2, model details md 2 where cn2.modol md2.model and md2.maker - cn2.id BONUS: Which country produces the most number of cars? To answer this question consider the following nested ag gregate function: +5 and cn2.country c2.countryid group by c2.countryid If you run the following, it will return a the total number of cars grouped by country 253 select c.countryid, (count (on.id)) as caracount You will need to combine these 2 queries together in some way in order to tell me which country pro- vides the most cars and how many. In order to get full credit, you can't use rownum or limit. The final output will look like this: from car names cn, countriea c car makera cm mode1 dotails md where cn.model mdmodel and md.maker-cm.id Berin Haile View Help Tell me what you want to do e Share Tip: counries.continents car makers.country, carmakers.id-model details.maker; model details.model = car_names.model; car_names.id - car_details.id number CONTINENT varchar2(15) CARS.CAR MAKERS CARS MODEL-DETAILS PKID PK COUNTRYID have /from MAKER varcha 2(15)avePMODELID number FULLNAME varchar2(25) COUNTRYNAME varchar2(20) FK PK AK MODEL varchar2(25) FK cOUNTRY are for PK,FKID CYLINDERS number EDISPL HORSEPOWER number WEIGHTnumber PKID FK MODEL varchar2(25) ACCEL YEAR

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions