0% found this document useful (3 votes)
803 views

DBMS Lab Assignment 8

The document provides instructions for creating tables, inserting sample data, and writing SQL queries on the tables for a database assignment. The tables to be created are Salesman_Details, Customer_Details, and Orders with attributes like salesman ID, name, city, commission, customer ID, name, city, grade, order number, purchase amount, date. Sample data is given to insert into these tables. 11 SQL queries are listed to display lists of salesmen, customers, orders by applying filters on attributes like city, purchase amount range, salesman commission, customer grade etc.

Uploaded by

Anshita Varshney
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (3 votes)
803 views

DBMS Lab Assignment 8

The document provides instructions for creating tables, inserting sample data, and writing SQL queries on the tables for a database assignment. The tables to be created are Salesman_Details, Customer_Details, and Orders with attributes like salesman ID, name, city, commission, customer ID, name, city, grade, order number, purchase amount, date. Sample data is given to insert into these tables. 11 SQL queries are listed to display lists of salesmen, customers, orders by applying filters on attributes like city, purchase amount range, salesman commission, customer grade etc.

Uploaded by

Anshita Varshney
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

B. Tech.

(CSE) III Semester 2020-2021


DBMS: Lab Assignment 8

1. Create following tables and put proper constraints wherever required:


Salesman_Details (Salesman_id, Name, City, Commission)
Customer_Details (Customer_id, Cust_name, City, Grade, Salesman_id)
Orders (Ord_no, Purch_amt, Ord_date, Customer_id, Salesman_id)

2. Insert data in the above tables:


(i) Some data for Salesman_Details table:
Salesman_id Name City Commission
5001 James New York 0.15
5002 Knite Paris 0.13

(ii) Some data for Customer_Details table:


Customer_id Cust_name City Grade Salesman_id
3002 Nick New York 100 5001
3005 Graham California 200 5002

(iii) Some data for Orders table:


Ord_no Purch_amt Ord_date Salesman_id Customer_id
70001 150.5 20-Jan-09 5002 3005
70009 270.65 27-Feb-09 5005 3001

3. Write SQL queries for the following:


(i) Display a list with salesman name, customer name and their cities for the salesmen and
customers who belong to the same city.
(ii) Display a list with order no, purchase amount, customer name and their cities for those orders
which have purchase amount between 500 and 2000.
(iii) Create a view, which contains a list with order no, purchase amount, customer name and
their cities for those orders which purchase amount between 500 and 2000.
(iv) Find which salesmen are working for which customer.
Hint: Display a list with customer name, customer city, salesman name and commission (for
iii and iv)
(v) Find the list of customers who appointed a salesman for their jobs who gets a commission
from the company more than 12%.
(vi) Find the list of customers who appointed a salesman for their jobs who does not live in the
same city where their customer lives, and gets a commission above 11%.
Hint: Display a list with customer name, customer city, salesman name, salesman city and
commission
(vii) Find the details of orders i.e. order number, order date, amount of order, which customer
gives the order and which salesman works for that customer and how much commission he
gets for an order.
(viii) Display a list in ascending order of customer name for the customers who work either
through a salesman or by own. (Hint: Display a list with customer name, customer city,
customer grade, salesman name and salesman city)
(ix) Display a list in ascending order of customer name for the customers who holds a grade
less than 300 and works either through a salesman or by own. (Hint: Display a list with
customer name, customer city, customer grade, salesman name and salesman city)
(x) Display a list in ascending order of salesman name for the salesmen who work either for
some customer or not yet join under any of the customers. (Hint: Display a list with
customer name, customer city, customer grade, salesman name and salesman city)
(xi) Take a cartesian product between salesman_details and customer_details i.e. each salesman
will appear for all customers and vice versa.

You might also like