Lab 03: Data Manipulation In this Lab we assume that you already have the Agents
ID: 3728574 • Letter: L
Question
Lab 03: Data Manipulation In this Lab we assume that you already have the Agents table with sample data inserted into it. If you don't have that table or you are using the Oracle Live SQL, you will need to create the Agents table and add data to it by copying and pasting the content of the file "Lab02_Data.txt" into an SQL Editor, then execute it. Provide the SQL statements that answer the following tasks: 1- How many agents are there? 2- What is the minimum, the average, and the maximum salaries of all agents? 3- What is the number of agents living in New York state and the sum of their salaries? 4- How many agents have NULL email addresses? 5- How many agents work in the branch B002 and have salaries greater than $40000? 6- How many different branches are there? 7- What is the number of agents in each state? 8- What is the number of agents in each branch and the average of their salaries?Explanation / Answer
Solution:
The first four subparts have been answered as per Chegg guidelines, please repost others.
1)
SELECT COUNT(agentID) FROM Agents
Explanation:
The COUNT function in SQL is qued to count the number of elements, so the number of agent id is equal to the number of agents in the agent table.
2)
SELECT MIN(salary), MAX(salary), AVERAGE(salary) FROM Agents
Explanation:
MIN, MAX, and AVERAGE functions are used to calculate min, max, and average respectively.
3)
SELECT COUNT(agentID) SUM(salary) FROM Agents WHERE city='NewYork'
Explanation:
SUM is used for totaling the salary
4)
SELECT COUNT(agentID) FROM Agents WHERE emailAddress IS NULL
Explanation:
IS NULL will check if the email adress field is null
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.