SQL Exercises 6 — Querying Multiple Tables

1. Find the salespersons and customers who live in same city. Return customer name, salesperson name and salesperson city.

2. Find all the customers along with the salesperson who works for them. Return customer name, and salesperson name.

3. Find those sales people who generated orders for their customers but not located in the same city. Return ord_no, cust_name, customer_id (orders table), salesman_id (orders table).

4. Find those orders made by customers. Return order number, customer name.

5. Find those customers where each customer has a grade and served by at least a salesperson who belongs to a city. Return cust_name as “Customer”, grade as “Grade” and order_no as “Order No.”.

6. Find those customers who served by a salesperson and the salesperson works at the commission in the range 12% to 14% (Begin and end values are included.). Return cust_name AS “Customer”, city AS “City”.

7. Find those orders executed by the salesperson, ordered by the customer whose grade is greater than or equal to 200. Compute purch_amt*commission as “Commission”. Return customer name, commission as “Commission%” and Commission.

8. Find those customers who made orders on October 5, 2012. Return customer_id, cust_name, city, grade, salesman_id, ord_no, purch_amt, and ord_date.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store