Create a function that calculate the total commission

Oracle 12c: SQL
3rd Edition
ISBN:9781305251038
Author:Joan Casteel
Publisher:Joan Casteel
Chapter1: Overview Of Database Concepts
Section: Chapter Questions
Problem 6MC
icon
Related questions
icon
Concept explainers
Question
100%

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
Transcribed Image Text: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
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
Transcribed Image Text: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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Oracle 12c: SQL
Oracle 12c: SQL
Computer Science
ISBN:
9781305251038
Author:
Joan Casteel
Publisher:
Cengage Learning