Skip to content

Commit 703f541

Browse files
authored
Create SQL Exercises: Prepare a list for which salesman are working for which customer along with city and commissions earned by the salesman
1 parent 4948c97 commit 703f541

1 file changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
SQL JOINS: Exercise-3 with Solution
2+
From the following tables write a SQL query to find the salesperson(s) and the customer(s) he handle. Return Customer Name, city, Salesman, commission.
3+
4+
Sample table: customer
5+
customer_id | cust_name | city | grade | salesman_id
6+
-------------+----------------+------------+-------+-------------
7+
3002 | Nick Rimando | New York | 100 | 5001
8+
3007 | Brad Davis | New York | 200 | 5001
9+
3005 | Graham Zusi | California | 200 | 5002
10+
3008 | Julian Green | London | 300 | 5002
11+
3004 | Fabian Johnson | Paris | 300 | 5006
12+
3009 | Geoff Cameron | Berlin | 100 | 5003
13+
3003 | Jozy Altidor | Moscow | 200 | 5007
14+
3001 | Brad Guzan | London | | 5005
15+
16+
Sample table: salesman
17+
salesman_id | name | city | commission
18+
-------------+------------+----------+------------
19+
5001 | James Hoog | New York | 0.15
20+
5002 | Nail Knite | Paris | 0.13
21+
5005 | Pit Alex | London | 0.11
22+
5006 | Mc Lyon | Paris | 0.14
23+
5007 | Paul Adam | Rome | 0.13
24+
5003 | Lauson Hen | San Jose | 0.12
25+
26+
27+
28+
29+
select a.cust_name as "Customer Name", a.city, b.name as"Salesman", b.commission
30+
from customer as a
31+
join salesman as b ON a.salesman_id=b.salesman_id;
32+

0 commit comments

Comments
 (0)