Preliminary Tasks: Task 1 In this Lab, it\'s assumed that you have already creat
ID: 3738258 • Letter: P
Question
Preliminary Tasks: Task 1 In this Lab, it's assumed that you have already created the Agents table and inserted sample data into it. If you don't have it, or if you are using Oracle Live SQL, you will need to create the table by copying and pasting the content of the file "Lab02_Data.txt" into an SQL Editor, then execute it. Task 2 Create the Branches table and insert sample data into it by executing the following code from your SQL Editor. CREATE TABLE Branches ( branchNo VARCHAR2(4), address VARCHAR2(50), city VARCHAR2(30), county VARCHAR2(30), state VARCHAR2(2), PRIMARY KEY (branchNo)) INSERT INTO Branches VALUES( BO02','366 Tiger Ln','Los Angeles','Los Angeles','CA'); INSERT INTO Branches VALUES('B005','55 Waydell St','Fairfield','Essex','NJ'); INSERT INTO Branches VALUES('B007,'1362 Alabama Rd','Riverside','Riverside','CA'); INSERT INTO Branches VALUES('B010','18 Harrison Rd','New York','New York','NY');Explanation / Answer
Solution:
The queries are given below
The first four subparts have been answered as per Chegg guidelines, please repost others.
1)
SELECT agentNo FROM Agents WHERE branchNo= (SELECT branchNo FROM Branches WHERE address= '18 Harison Rd.')
2)
SELECT agentNo FROM Agents WHERE salary> AVG(salary)
3)
SELECT fName, lName, salary, branchNo, address FROM Agents INNER JOIN Branches ON Branches.branchNo= Agents.branchNo ORDER BY salary
4)
SELECT COUNT(agentNo), SUM(salary) FROM Agents GROUP BY state.
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)