Skip to content

Commit 3fcc8a7

Browse files
authored
Create SQL Exercises: Make a list of customers who appointed a salesman for their jobs who gets a commission is above 12%
1 parent 703f541 commit 3fcc8a7

1 file changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
https://www.w3resource.com/sql-exercises/sql-joins-exercise-4.php
2+
3+
SQL JOINS: Exercise-4 with Solution
4+
From the following tables write a SQL query to find those salespersons who received a commission from the company more than 12%. Return Customer Name, customer city, Salesman, commission.
5+
6+
7+
Sample table: salesman
8+
salesman_id | name | city | commission
9+
-------------+------------+----------+------------
10+
5001 | James Hoog | New York | 0.15
11+
5002 | Nail Knite | Paris | 0.13
12+
5005 | Pit Alex | London | 0.11
13+
5006 | Mc Lyon | Paris | 0.14
14+
5007 | Paul Adam | Rome | 0.13
15+
5003 | Lauson Hen | San Jose | 0.12
16+
17+
Sample table: customer
18+
customer_id | cust_name | city | grade | salesman_id
19+
-------------+----------------+------------+-------+-------------
20+
3002 | Nick Rimando | New York | 100 | 5001
21+
3007 | Brad Davis | New York | 200 | 5001
22+
3005 | Graham Zusi | California | 200 | 5002
23+
3008 | Julian Green | London | 300 | 5002
24+
3004 | Fabian Johnson | Paris | 300 | 5006
25+
3009 | Geoff Cameron | Berlin | 100 | 5003
26+
3003 | Jozy Altidor | Moscow | 200 | 5007
27+
3001 | Brad Guzan | London | | 5005
28+
29+
30+
# Solution
31+
select a.cust_name as "Customer Name", a.city, b.name as"Salesman", b.commission
32+
from customer as a
33+
join salesman as b ON a.salesman_id=b.salesman_id
34+
where b.commission >.12
35+
order by b.commission desc
36+
limit 4
37+
;

0 commit comments

Comments
 (0)