In SQL, running on an Oracle database, write a query for each problem that solve
ID: 3586562 • Letter: I
Question
In SQL, running on an Oracle database, write a query for each problem that solves the task.
1) Find the total damage amount from all accidents in which the cars manufactured by BMW were involved -- note: the answer should include the damage produced to other cars involved in the same accidents with the BMW cars.
2) Find the average damage amount from all accidents in which the cars owned by Rubens Barrichello were not involved.
Note: Each query should produce the results shown below respectively. Please ensure your code produces similar results.
Query 1 Result:
TOT_DAM
29000
Query 2 Result:
AVG_DAM
4500
Explanation / Answer
Query 1:
select sum(Damage_amt) as TOT_DAM from participated where Report_nr in (select Report_nr from participated where Licence in (select Licence from car where Model='BMW'));
Query 2:
select avg(Damage_amt) from participated where Driver_id not in (select Driver_id from person where Name='RB');
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.