SQL ASSIGNMNET(BCA-3rd SEM)
Note: Question 1-6 are based on worker, bonus and title table(Assignment -1)
Table – Worker
WORKER_ID FIRST_NAME LAST_NAME SALARY JOINING_DATE DEPARTMENT
001 Monika Arora 100000 2014-02-20 09:00:00 HR
002 Niharika Verma 80000 2014-06-11 09:00:00 Admin
003 Vishal Singhal 300000 2014-02-20 09:00:00 HR
004 Amitabh Singh 500000 2014-02-20 09:00:00 Admin
005 Vivek Bhati 500000 2014-06-11 09:00:00 Admin
006 Vipul Diwan 200000 2014-06-11 09:00:00 Account
007 Satish Kumar 75000 2014-01-20 09:00:00 Account
008 Geetika Chauhan 90000 2014-04-11 09:00:00 Admin
Table – Bonus
WORKER_REF_ID BONUS_DATE BONUS_AMOUNT
1 2016-02-20 00:00:00 5000
2 2016-06-11 00:00:00 3000
3 2016-02-20 00:00:00 4000
1 2016-02-20 00:00:00 4500
2 2016-06-11 00:00:00 3500
Table – Title
WORKER_REF_ID WORKER_TITLE AFFECTED_FROM
1 Manager 2016-02-20 00:00:00
2 Executive 2016-06-11 00:00:00
8 Executive 2016-06-11 00:00:00
5 Manager 2016-06-11 00:00:00
4 Asst. Manager 2016-06-11 00:00:00
7 Executive 2016-06-11 00:00:00
6 Lead 2016-06-11 00:00:00
3 Lead 2016-06-11 00:00:00
Q1. Create Table Bonus, Worker, and Title as per given data using create command.
Q2. Insert tuples as per given data in above tables.
Q3. Write an SQL query to fetch “FIRST_NAME” from Worker table.
Q4. Write an SQL query to fetch “FIRST_NAME” from Worker table in upper case.
Q5. Write an SQL query to print all Worker details from the Worker table order by
FIRST_NAME Ascending.
Q6. Write an SQL query to print details of the Workers whose SALARY lies between
100000 and 500000.
Table Name:- Employee (Question 7-10 are based on Employee and Empdept tables)
(Assignment-2)
Empid EmpName Department ContactNo EmailId EmpHeadId
Table :- EmpDept
DeptId DeptName Dept_off DeptHead
E-101 HR Monday 105
E-102 Development Tuesday 101
E-103 Hous Keeping Saturday 103
E-104 Sales Sunday 104
E-105 Purchage Tuesday 104
Q7. Select the detail of the employee whose name start with P.
Q8. Select the detail of employee whose emailId is in gmail.
Q9. Select the details of the employee who work either for department E-104 or E-102.
Q10. What is the department name for DeptID E-102?
Assignment 3(Question 11 and 12 do from salesman and customer table)
From the following tables write a SQL query to find the salesperson and customer who reside
in the same city. Return Salesman, cust_name and city
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 table: customer
customer_id | cust_name | city | grade |
salesman_id
-------------+----------------+------------+-------
+-------------
3002 | Nick Rimando | New York | 100 |
5001
3007 | Brad Davis | New York | 200 |
5001
3005 | Graham Zusi | California | 200 |
5002
3008 | Julian Green | London | 300 |
5002
3004 | Fabian Johnson | Paris | 300 |
5006
3009 | Geoff Cameron | Berlin | 100 |
5003
3003 | Jozy Altidor | Moscow | 200 |
5007
3001 | Brad Guzan | London | |
5005
Q11. From the following tables write a SQL query to find the salesperson and customer who
reside in the same city. Return Salesman, cust_name and city.
Q12. From the following tables write a SQL query to find the salesperson(s) and the
customer(s) he represents. Return Customer Name, city, Salesman, commission.
Q13. Mention Primary Key constraint on salesman and customer table in primary key .
Q14. Apply update, alter ,delete command in salesman and customer table.