PATANJALI RISHIKUL, PRAYAGRAJ

Size: px
Start display at page:

Download "PATANJALI RISHIKUL, PRAYAGRAJ"

Transcription

1 (a) (b) (c) (d) (e) (f) (g) (h) PATANJALI RISHIKUL, PRAYAGRAJ Assignment # 1 1. Create a database called MyOffice 2. Open database 3. Given the following EMPLOYEE relation, answer the questions. TABLE : EMP EMPN ENAME JOB MGR HIREDATE SAL COM DEPTNO O M 7369 Sunita Sharma CLERK NULL Ashok Singhal SALESMAN Sumit Avasthi SALESMAN Jyoti Lamba MANAGER NULL Martin S. SALESMAN Binod Goel Manager NULL Chetan Gupta Manager NULL Sudhir Rawat Analyst NULL Kavita Sharma President NULL NULL Tushar Tiwari Salesman NULL Anand Rathi Clerk NULL Jagdeep Rana Clerk NULL Sumit Vats Analyst Manoj Kaushik Clerk NULL 10 Create the above table with proper constraints. Add at least 20 record as the given above. Display all the records (all columns) from table emp. Display EMPNO and ENAME of all employees from the table. To list all names, hiredate and salary of all employees. To display the employee name and the incremented value of SAL as SAL+300. To list the employee name and its annual salary (Annual sal = 12*sal+1000) Display the ename and sal where comm. Is NULL (i) To list the distinct department number from the table. (j) (k) To list the unique jobs from the table. To list the salary where salary is less than the commission. (l) Write a query to display employee name and salary to those employee who don t have their salary in the range of to

2 (m) To list the mgr which in 7902,7566,7788. (n) To list the ename starting with S. (o) To list the ename and sal of employees whose salary is greater than or equal to (p) (q) (r) Write a query to display name, job, salary and hiredate of employees who are hired between May 20,1991 and December 31, 2001 order the query in ascending order of hiredate. Write a query to display the name of employee who is having L as any alphabet of the name. To display the employee name and job of employees hired between Feb 20,1991 and Dec 31,1991. (s) Display the ename and deptno of all employee in department 20 and 30 in alphabetical ORDER BY name. (t) To list the name and salary of all the employees who are hired in (u) (v) To list all the employees who do not have manager. To list all name and salary of all employees who earn commission. (w) To list the names of all employees where 2 nd letter of their name is an a. (x) (y) (z) (aa) To list the names and job of all the employees who work in deprtment 20 and their manager is Display distinct salary of employees from table emp. Create a query that produces display in the format <employee name> earns Rs.<sal> monthly and working as <job> from table emp. Display ename joined with job with heading Employee, Sal * 12 as Total Salary from table emp. (bb) (cc) (dd) (ee) (ff) Write a query to display Ename and Sal of Employees whose salary is greater than or equal to from table Emp. Write a query to display Ename, salary and department no who are not getting commission from table emp. Write a query to display employee no, name and sal * 12 as Annual Salary whose commission is not NULL from the table emp. Write a query to display employee name and salary of those employees who don t have their salary in the range of to Write a query to display name, job, salary and hiredate of employees who are hired between Feb and May 1,1991. Order the query in ascending order of hiredate. (gg) Write a query to display the name and hire date of all employees who were hired in 1992 (hh) (ii) (jj) Write a query to display the name of employee whose name contains A as 3 rd alphabet. Write a query to display the name of employees whose name contains T as the last alphabet. Write a query to display the name of employees whose name contains M as first alphabet L as 3 rd alphabet.

3 Assignment # 2 Write SQL commands for the questions the basis of table PAY. TABLE : PAY No. Name Salary Area Age Grade Dept 1 Krippe West 45 C Civil 2 Ravina South 38 A Elec 3 Karan North 52 B Comp 4 Tarun East 29 A Civil 5 Aryan 5000 West 30 A Elec a. To display the names of all employees who are in the area South. b. To display name and age of all employees whose age > 40. c. To display list of all employees whose salary >=30000 and <= d. To insert 5 new rows with meaningful data records. e. Change the salary with Salary for those employees who are working in Comp dept. f. Remove all records of those employees who are above 50 yrs of age and their name started with A g. Show all records of Grade A. h. Show all records who earns above and their dept should be Civil. i. Find out 15% Commission on salary. j. Show list of all employees who are working in different departments group wise. k. Count all the employees who are working in Comp dept. l. Calculate Total salary of each department.

4 Assignment # 3 1. In a database company, there are two tables given below: Table : Sales SalesmanID Name Sales LocationID S1 Anita Singh Arora S2 Y.P. Singh S3 Tina Jaiswal S4 Gurdeep Singh S5 Simi Faizal Table : Location LocationId LocationName 101 Delhi 102 Mumbai 103 Kolkata 104 Chennai Write SQL queries for the following: (a) To display SalesmanId,Name of salesmen, LocatinId with corresponding location names. (b) To display names of salesmen, sales and corresponding location names who have achieved Sales more than (c) To display names of those salesmen who have Singh in their names. (d) To change the LocationId to 104 of the salesman with ID as S3 in the table sales. (e) To display LocationId, LocationName and total sales of all locations. 2. In a database there are two tables ITEM and CUSTOMER as shown below: Table : ITEM ID ItemName Company Price 1001 Moisturiser XYZ Sanitizer LAC Bath Soap COP Shampoo TAP Lena Solution COP 350

5 Table : Customer C_ID CustomerName City ID 01 Samridhi Ltd. New Delhi Big Line Inc Mumbai New Delhi Tom N Jerry Bangalore 1003 Write the command in SQL queries for the following: (i) (ii) To display the details of items whose Price is in the range of 40 and 95(both values included) To display the CustomerName, city from table customer and ItemName and Price from table item, with their corresponding matching ID. (iii) To increase the price of all the products by 50 (iv) To display Item name, company, price, city, customer name of them whose id is 1002