SQL Assignment 2018
SQL Assignment 2018
SQL Assignment 2018
2
DBMS Lab
Q1: Modify the following Employee table to add two more columns salary,mgr to the emp table. Add
salary column with constraint greater than zero and modify the width of sal column. Now perform the
following queries on following tables:-
Employee(empno,ename,deptno,job,hiredate)
Department(deptno,dname,loc)
Q2: Create a table client master with the following fields client_no, name, address1, address2, city,
state, pin_code, remarks, balance due and add the constraints:-
TABLE NAME:Salesmen
SNUM SNAME CITY COMMISSION
-------------------------------------------------------
1001 Piyush London 12 %
1002 Sejal Surat 13 %
1004 Miti London 11 %
1007 Rajesh Baroda 15 %
1003 Anand New Delhi 10 %
TABLE NAME:Orders
ONUM AMOUNT ODATE CNUM SNUM
-------------------------------------------------------
3001 18.69 10/03/97 2008 1007
3003 767.19 10/03/97 2001 1001
Q4: Solve the following queries using above databases and group by clause.
1. Find out the largest orders of salesman 1002 and 1007.
2. Count all orders of October 3, 1997.
3. Calculate the total amount ordered.
4. Calculate the average amount ordered.
5. Count the no. of salesmen currently having orders.
6. Find the largest order taken by each salesman on each date.
7. Find the largest order taken by each salesman on 10/03/1997.
8. Count the no. of different non NULL cities in the Customer table.
9. Find out each customer's smallest order.
10. Find out the first customer in alphabetical order whose name begins with 'G'.
11. Count the no. of salesmen registering orders for each day.