Create a function that calculate the total commission
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.
Create a function that calculate the total commission
(code of tables
CREATE TABLE Salesman (
[salesman_id] INT,
[name] NVARCHAR(10),
[City] NVARCHAR(8),
[commission] NUMERIC(3, 2),
);
INSERT INTO Salesman VALUES
(5001,N'James Hoog',N'New York',0.15),
(5002,N'Nail Knife',N'Paris',0.13),
(5005,N'Pit Alex',N'London',0.11),
(5006,N'Mc Lyon',N'Paris',0.14),
(5007,N'Paul Adam',N'Rome',0.13),
(5003,N'Lauson Hen',N'San Jose',0.12);
CREATE TABLE Customer (
[customer_id] INT,
[cust_name] NVARCHAR(14),
[city] NVARCHAR(10),
[grade] INT,
[salesman_id] INT
);
INSERT INTO Customer VALUES
(3002,N'Nick Rimando',N'New York',100,5001),
(3007,N'Brad Davis',N'New York',200,5001),
(3005,N'Graham Zusi',N'California',200,5002),
(3008,N'Julian Green',N'London',300,5002),
(3004,N'Fabian Johnson',N'Paris',300,5006),
(3009,N'Geoff Cameron',N'Berlin',100,5003),
(3003,N'Jozy Altidor',N'Moscow',200,5007),
(3001,N'Brad Guzan',N'London',NULL,5005);
)
-in Microsoft SQL server
![Table: Customer
customer_id |
cust_name
city
I grade | salesman_id
3002 | Nick Rimando
3007 | Brad Davis
3005 | Graham Zusi
3008 | Julian Green
3004 | Fabian Johnson | Paris
3009 | Geoff Cameron | Berlin
3003 | Jozy Altidor
3001 | Brad Guzan
100 |
| New York
|New York
| California |
| London
5001
200 |
5001
200
5002
300
5002
300
5006
100
5003
Moscow
200 |
5007
| London
5005](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F924e4664-9ae2-4745-951d-a9d3dd0dcbd4%2Fd4d1132b-fb8f-4075-b037-a0554c35049a%2F6knrvxg_processed.jpeg&w=3840&q=75)
![Table: Salesman
salesman_id |
city
I commission
name
5e01 | James Hoog | New York |
see2 | Nail Knite | Paris
| London
| Paris
5e07 | Paul Adam | Rome
5003 | Lauson Hen | San Jose|
0.15
0.13
5e05 | Pit Alex
0.11
se06 | MC Lyon
0.14
0.13
0.12](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F924e4664-9ae2-4745-951d-a9d3dd0dcbd4%2Fd4d1132b-fb8f-4075-b037-a0554c35049a%2Fch3gc2u_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)