1.
Display All Salespeople
SQL Basic Select Statement: Exercise-1 with
Solution
Write a SQL statement that displays all the information about all salespeople.
Sample table: salesman
salesman_id | name | city | commission
-------------+------------+----------+------------
5001 | James Hoog | New York | 0.15
5002 | Nail Knite | Paris | 0.13
5005 | Pit Alex | London | 0.11
5006 | Mc Lyon | Paris | 0.14
5007 | Paul Adam | Rome | 0.13
5003 | Lauson Hen | San Jose | 0.12
Sample Solution:
SQL Code:
SELECT *
FROM salesman;
Output of the Query:
salesman_id name city commission
5001 James Hoog New York 0.15
5002 Nail Knite Paris 0.13
5005 Pit Alex London 0.11
5006 Mc Lyon Paris 0.14
5007 Paul Adam Rome 0.13
5003 Lauson Hen San Jose 0.12
Note: Use * to get a complete list of the columns from a table.
Write a SQL statement to display specific columns such as names and
commissions for all salespeople.
Write a query to display the columns in a specific order, such as order date,
salesman ID, order number, and purchase amount for all orders.
From the following table, write a SQL query to locate salespeople who live
in the city of 'Paris'. Return salesperson's name, city.
Sample table
Output of the Query:
name city
Nail Knite Paris
Mc Lyon Paris
From the following table, write a SQL query to find customers whose grade
is 200. Return customer_id, cust_name, city, grade, salesman_id.
Sample table: customer
Output of the Query:
customer_id cust_name city grade salesman_id
3007 Brad Davis New York 200 5001
3005 Graham Zusi California 200 5002
3003 Jozy Altidor Moscow 200 5007
From the following table, write a SQL query to find orders that are
delivered by a salesperson with ID. 5001. Return ord_no, ord_date,
purch_amt.
Sample table: orders
SELECT ord_no, ord_date, purch_amt
FROM Orders
WHERE sales_id = “5001”
Output of the Query:
ord_no ord_date purch_amt
70002 2012-10-05 65.26
70005 2012-07-27 2400.60
70008 2012-09-10 5760.00
70013 2012-04-25 3045.60
____________________________________
1. From the following table, write a SQL query to find out which nurses have
not yet been registered. Return all the fields of nurse table.