Input: SalesPerson table: ----+- +------ I sales_id | name | salary | commission_rate | hire_date ----- | 1 | 2 | 3 | John | 100000 | 6 | 12000 | Mark | 65000 | 25000 | Alex | 5000 | 5 | 12 | 25 | 10 | 4/1/2006 | 5/1/2010 | 12/25/2008 | | 1/1/2005 | 2/3/2007 | Amy | Pam | 5 +- Company table: +- | com id | name city +- | 1 | 2 | 3 | 4 | RED | ORANGE | New York| | YELLOW | Boston | GREEN | Boston | Austin +-- Orders table: +- | order id | order date | com id | sales id | amount | | 1 | 2 | 3 | 1/1/2014 | 2/1/2014 | 3/1/2014 | 4/1/2014 | 3 | 4 | 1 | 1 | 10000 | 5000 | 50000 | 25000 | 5 | 1 4 4 Write an SQL query to report the names of all the salespersons who did not have any orders related to the company with the name "RED". Return the result table in any order. The results should be: Output: +---- I name | +------+ | Amy | Mark | | Alex | +------+

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Write a clear full sql query please

Create the following table in your database with the following schema:
Table: SalesPerson
| Column Name
| Туре
+---
| sales id
| int
| varchar |
| int
I name
| salary
| commission_rate | int
| hire_date
I date
+----
----+
sales_id is the primary key column
Each row of this table indicates the name and the ID of a salesperson
alongside their salary, commission rate, and hire date.
this table.
Table: Company
| Column Name | Type
| int
| varchar I
| varchar |
| com_id
| name
| city
-----+
com_id is the primary key column for this table.
Each row of this table indicates the name and the ID of a company and the
city in which the company is located.
Table: Orders
| Column Name | Type |
+-
| order id
| order date
| com id
| sales id
| int
| date |
| int
| int
| int
| amount
+----
-----+
order id is the primary key column for this table.
com id is a foreign key to com id from the Company table.
sales id is a foreign key to com id from the SalesPerson table.
Each row of this table contains information about one order. This includes
the ID of the company, the ID of the salesperson, the date of the order, and
the amount paid.
Add the following data to your tables:
Transcribed Image Text:Create the following table in your database with the following schema: Table: SalesPerson | Column Name | Туре +--- | sales id | int | varchar | | int I name | salary | commission_rate | int | hire_date I date +---- ----+ sales_id is the primary key column Each row of this table indicates the name and the ID of a salesperson alongside their salary, commission rate, and hire date. this table. Table: Company | Column Name | Type | int | varchar I | varchar | | com_id | name | city -----+ com_id is the primary key column for this table. Each row of this table indicates the name and the ID of a company and the city in which the company is located. Table: Orders | Column Name | Type | +- | order id | order date | com id | sales id | int | date | | int | int | int | amount +---- -----+ order id is the primary key column for this table. com id is a foreign key to com id from the Company table. sales id is a foreign key to com id from the SalesPerson table. Each row of this table contains information about one order. This includes the ID of the company, the ID of the salesperson, the date of the order, and the amount paid. Add the following data to your tables:
Input:
SalesPerson table:
+----------
| sales id | name | salary | commission rate | hire date
| 1
| 2
| 3
| 4
| 5
| John | 100000 | 6
| 12000
| Mark | 65000
| 25000
| Alex | 5000
| 5
| 12
| 25
| 10
| 4/1/2006
| 5/1/2010
| 12/25/2008 I
| 1/1/2005
| 2/3/2007
| Amy
| Pam
+---
Company table:
+---
com_id | name
| city
| 1
| 2
| 3
| 4
| RED
| ORANGE | New York |
| YELLOW | Boston
| GREEN
| Boston
| Austin
+--
Orders table:
+---------
| order id | order date | com id | sales id | amount |
+--
-------+
| 1
| 2
| 3
| 4
| 1/1/2014
| 2/1/2014
| 3/1/2014
| 4/1/2014
| 3
| 4
| 1
| 1
| 4
| 5
| 1
| 4
| 10000
| 5000
| 50000
| 25000
Write an SQL query to report the names of all the salespersons who did not have any orders related
to the company with the name "RED".
Return the result table in any order.
The results should be:
Output:
+----
| name |
+------+
| Amy
| Mark |
| Alex |
+------+
Transcribed Image Text:Input: SalesPerson table: +---------- | sales id | name | salary | commission rate | hire date | 1 | 2 | 3 | 4 | 5 | John | 100000 | 6 | 12000 | Mark | 65000 | 25000 | Alex | 5000 | 5 | 12 | 25 | 10 | 4/1/2006 | 5/1/2010 | 12/25/2008 I | 1/1/2005 | 2/3/2007 | Amy | Pam +--- Company table: +--- com_id | name | city | 1 | 2 | 3 | 4 | RED | ORANGE | New York | | YELLOW | Boston | GREEN | Boston | Austin +-- Orders table: +--------- | order id | order date | com id | sales id | amount | +-- -------+ | 1 | 2 | 3 | 4 | 1/1/2014 | 2/1/2014 | 3/1/2014 | 4/1/2014 | 3 | 4 | 1 | 1 | 4 | 5 | 1 | 4 | 10000 | 5000 | 50000 | 25000 Write an SQL query to report the names of all the salespersons who did not have any orders related to the company with the name "RED". Return the result table in any order. The results should be: Output: +---- | name | +------+ | Amy | Mark | | Alex | +------+
Expert Solution
Step 1

Select name from salesPerson join orders on salesperson.sales_id=orders.sales_id where (select com_id from orders join company on orders.com_id=company.com_id where name !="RED")

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education