Question: I created the table already , can i please get hwlp with questions 1-10? create table carprice ( ID int primary key, CarType varchar(20), Price
I created the table already , can i please get hwlp with questions 1-10?
create table carprice
(
ID int primary key,
CarType varchar(20),
Price decimal(10,2),
GallonsPer100miles decimal(5,2),
MPGcity decimal(5),
MPGhighway decimal(5),
BrandID int
);
insert into carprice values
(1,'Midsize',15.7,3.8,22,31,1),
(2,'Large',20.8,4.2,19,28,1),
(3,'Large',23.7,4.9,16,25,1),
(4,'Midsize',26.3,4.3,19,27,2),
(5,'Large',34.7,4.9,16,25,2),
(6,'Midsize',40.1,4.9,16,25,3),
(7,'Compact',13.4,3.3,25,36,1),
(8,'Compact',11.4,3.4,25,34,4),
(9,'Sporty',15.1,4.2,19,28,1),
(10,'Midsize',15.9,4,21,29,5),
(11,'Van',16.3,4.9,18,23,2),
(12,'Van',16.6,5.7,15,20,2),
(13,'Large',18.8,4.7,17,26,1),
(14,'Sporty',38,4.8,17,25,4),
(15,'Large',18.4,4.2,20,28,1),
(16,'Compact',15.8,3.9,23,28,3),
(17,'Large',29.5,4.3,20,26,4),
(18,'Small',9.2,3.2,29,33,1),
(19,'Small',11.3,3.8,23,29,1),
(20,'Compact',13.3,4.1,22,27,4),
(21,'Van',19,5.3,17,21,2),
(22,'Midsize',15.6,4.2,21,27,3),
(23,'Sporty',25.8,4.8,18,24,3),
(24,'Small',12.2,3.2,29,33,5),
(25,'Large',19.3,4.2,20,28,2),
(26,'Small',7.4,3.1,31,33,1),
(27,'Small',10.1,3.8,23,30,2),
(28,'Compact',11.3,4.1,22,27,3),
(29,'Sporty',15.9,3.9,22,29,1),
(30,'Sporty',14,3.7,24,30,1),
(31,'Van',19.9,5.7,15,20,1),
(32,'Midsize',20.2,3.9,21,30,3),
(33,'Large',20.9,4.5,18,26,4),
(34,'Midsize',34.3,4.7,17,26,2),
(35,'Large',36.1,4.5,18,26,3),
(36,'Sporty',14.1,4.1,23,26,2),
(37,'Midsize',14.9,4.4,19,26,1),
(38,'Compact',13.5,3.6,24,31,1),
(39,'Midsize',16.3,3.7,23,31,1),
(40,'Van',19.5,4.9,18,23,1),
(41,'Large',20.7,4.2,19,28,1),
(42,'Sporty',14.4,3.8,23,30,3),
(43,'Small',9,2.8,31,41,2),
(44,'Compact',11.1,3.7,23,31,3),
(45,'Sporty',17.7,4.2,19,28,2),
(46,'Midsize',18.5,4.3,19,27,1),
(47,'Large',24.4,4.2,19,28,4),
(48,'Small',11.1,3,28,38,5);
DROP TABLE CarBrand
create table CarBrand
(
BrandID int,
CarBrand varchar(20)
)
insert into CarBrand values
(1,'Toyota'),
(2,'Honda'),
(3,'Hyundai'),
(4,'BMW'),
(5,'Chevrolet'),
(6,'GMC')
Question1:
Write a query to find the average miles per gallon on highway
Question2:
Write a query to find the maximun miles per gallon on city
Question3:
Write a query to find the minimum miles per gallon on city
Question4:
Write a query to find the average price of the cars owned by the retailer
Question5:
Write a query to find the average price of the Midsize cars
Question6:
Write a query to return the cartype, number of cars in each cartype and average price of each cartype .
Question7:
Write a query to return the cartype, number of cars in each cartype and average price of each cartype. The result set must display only the cartypes that have average price
greater than 20 (in thousands of dollars )
Question8:
Write a query to return the carbrand, cartype and average price of a specific carbrand-cartype,
number of cars belonging to a specific carband-cartype. Sort the results in ascending order of the carbrand
for example
Carbrand Cartype Average Price Number of cars
BMW Compact 12.350000 2
BMW Large 24.933333 3
BMW Sporty 38.000000 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
