DBMS Lab Assignment2
DBMS Lab Assignment2
1. Create the table Customer, Salesman, and order as per the schema given below and
insert any ten suitable entries in created table.
Customer (Cust_ID, cust_name,City,Grade,Salesman_ID) ,
Salesman (SalesMan_ID,Name, Commission,City)
Allowed Data Types of Customer table are:
Cust_ID INTEGER
Cust_name varchar
City varchar
Grade INTEGER
Salesman_ID INTEGER
Q.1.1 Write a query to find those customers with their name and those salesmen with their
name and city who lives in the same city.
Expected Output:
Nick Rimando James Hoog New York
Brad Davis James Hoog New York
Q.1.2 Write a SQL statement to find the names of all customers along with the salesmen who
works for them.
Expected Output:
Nick Rimando James Hoog
Brad Davis James Hoog
Graham Zusi Nail Knite
Julian Green Nail Knite
Q.1.3 Write a query that produces all customers with their name, city, salesman and
commission, who served by a salesman and the salesman works at a rate of the commission
within 12% to 14%.
Expected Output:
Customer City Salesman commission
Graham Zusi California Nail Knite 0.13
Julian Green London Nail Knite 0.13
Expected Output:
3005 Graham Zusi California 200 5002 70001 150.5 2012-10-05 3005 5002
Q.1.5 Write a SQL statement that produces all orders with the order number, customer name,
commission rate and earned commission amount for those customers who carry their grade is
200 or more and served by an existing salesman.
Expected Output:
ord_no cust_name Commission% Commission
70005 Graham Jusi 0.13 19.565
2. Create the table as per given schema and insert any ten suitable entries in created table.
Book (Book_No, Title , Author, Price)
Allowed Data Types of Columns in State table are:
Book_No INTEGER
Title varchar
Author varchar
Price BigInt
Q.3.1. Write a query to find the name (first_name, last_name), department_id and name of all the
employees.
Q.3.2. Write a query to display department name, name (first_name, last_name), hire date, salary of
the manager for all managers whose experience is more than 15 years.
Q.3.3 Write a query to display job title, employee name, and the difference between salary of the
employee and minimum salary for the job.
Q.3.4 Write a query to display the job title and average salary of employees.
Q3.5 Write a query to get the maximum and minimum salary from employees table.
Q.3.6. Write a SQL statement to increase the salary of employees under the department 40, 90 and
110 according to the company rules that, salary will be increased by 25% for the department 40, 15%
for department 90 and 10% for the department 110 and the rest of the departments will remain same.
Q.3.7. Write a SQL statement to get all information about the employees but limiting to only 7.
Q.3.8. Write a SQL statement to change salary of employee to 8000 whose ID is 105, if the existing
salary is less than 5000.
Q.3.9 Write a query to display the first_name of all employees who have both "b" and "c" in their first
name.
Q.3.10. Write a query to get monthly salary (round 2 decimal places) of all employees.
Q.3.11. Write a query to get the number of employees working with the company.
Q.3.12. Write a query to get the average salary and number of employees in the employees table.
Q.3.13. Write a query to get the total salaries payable to employees.
Q.3.14. Write a query to get the names (first_name, last_name), salary, PF of all the employees (PF is
calculated as 15% of salary).