Sarthaks Test
0 votes
in Information Technology by (47.5k points)
closed by

A relation Vehicles is given below :

V_no TypeCompanyPriceQty
M0892Mini vanDatsun150000026
R2409Mini vanMahindra35000015

Write SQLcommands to:

a. Display the average price of each type of vehicle having quantity more than 20.

b. Count the type of vehicles manufactured by each company.

c. Display the total price of all the types of vehicles.

1 Answer

+1 vote
by (46.4k points)
selected by
Best answer

a. select Type, avg(Price) from Vehicle group by Type having Qty>20;

b. select Company, count(distinct Type) from Vehicle group by Company;

c. Select Type, sum(Price* Qty) from Vehicle group by Type;

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.