Question: 1- Create and save a .sql script file with 3 SELECT queries that produce the results below. Queries: a) Salesperson Jungpil recently worked with a
1- Create and save a .sql script file with 3 SELECT queries that produce the results below.
Queries:
a) Salesperson Jungpil recently worked with a customer who he would like to contact again. Unfortunately, he cannot quite remember if the customers last name was Hansen or Hanson. Construct a query to help Jungpil find the correct customer to follow up with. Show the customers first name, last name, and phone number.
b) Generate a query to find the average income of customers who purchased a car on their interaction.
c). Construct a totals query to examine the relationship between salespeople and the annual income of the customers they target in their interactions. Show the salespeoples first name and the average annual income of their customers in your result. HINT: You do not need to include a criterion for Purchase in this query.
CREATE TABLE IF NOT EXISTS `salesperson` ( `SalesID` varchar(45) NOT NULL, `SalesFirstName` varchar(45) DEFAULT NULL, `SalesLastName` varchar(45) DEFAULT NULL, `SalesHireDate` date DEFAULT NULL, `SalesSalary` decimal(9,2) DEFAULT NULL, PRIMARY KEY (`SalesID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; CREATE TABLE IF NOT EXISTS `customer` ( `CustomerID` varchar(45) NOT NULL, `CustomerFirstName` varchar(45) DEFAULT NULL, `CustomerLastName` varchar(45) DEFAULT NULL, `CustomerPhone` varchar(45) DEFAULT NULL, `AnnualIncome` decimal(9,2) DEFAULT NULL, `CreditRating` varchar(45) DEFAULT NULL, PRIMARY KEY (`CustomerID`), KEY `CreditRating` (`CreditRating`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; CREATE TABLE IF NOT EXISTS `creditrating` ( `CreditID` varchar(45) NOT NULL, `CreditDescription` varchar(45) DEFAULT NULL, `MinFICO` int(11) DEFAULT NULL, `MaxFICO` int(11) DEFAULT NULL, `Comments` varchar(100) DEFAULT NULL, PRIMARY KEY (`CreditID`), CONSTRAINT `CreditID` FOREIGN KEY (`CreditID`) REFERENCES `customer` (`creditrating`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
