Since October 7, 2023, Israel has murdered 57,200 Palestinians, out of whom, 18,188 were children. Please consider donating to Palestine Children's Relief Fund.
SQLite3 IconSQLite3
0
0
Intermediate

Sales Employees with Most Sales Revenue

As Michael Scott prepare to go on a sales call with his dream sales team to secure Lackawanna County as a client, he realizes that there is only room for 3 people on his Chrysler Sebring besides himself. This means he must choose only 3 sales department employees to go with him on this sales call. That's not good, Michael makes terrible decisions when under pressure.

Luckily, he is able to look up the sales history of each salesperson and choose the top 3 salespeople according to the amount of sales revenue they have brought in.

Exercise

Help Michael gather his employees for his dream team by obtaining the names of the top 3 salespeople with the highest sales revenue. These can be permanent employees from the Sales department only. The Employees table provides the list of all employees and their information, and the Sales table provides a history of sales for Dunder Mifflin. The sales revenue in each sale in the Sales table can be found by multiplying the quantity and price columns. Your output table should display only the first_name and last_name of the top 3 employees, as well as a column called sales_revenue that represents the amount of sales revenue brought in by the employee.

Tables

Employees

Column NameData Type
employee_idINT PRIMARY KEY
first_nameVARCHAR
last_nameVARCHAR
date_of_birthTEXT
departmentVARCHAR
employment_typeVARCHAR

Sales

Column NameData Type
sale_idINT PRIMARY KEY
client_nameVARCHAR
product_nameVARCHAR
salesperson_idINT (FOREIGN KEY Employees.employee_id)
dateTEXT
quantityINT
priceDECIMAL
Login to Start Coding
-- rewrite this query
SELECT * FROM Employees;