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 | +------+
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Write a clear full sql query please
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
This is a popular solution!
Step by step
Solved in 2 steps