Professional Documents
Culture Documents
Instructions:
1. Logon to the Personal MS-SQL Server.
2. Store all your SQL commands in the .SQL file on your system desktop.
PART-A
EMP TABLE
BONUS TABLE
ENAME CHARACTER 20
JOB CHARACTER 15
SAL NUMBER 8, 2
COMM NUMBER 8, 2
SALGRADE TABLE
DEPT TABLE
PROJ TABLE
a. Add the following records as per the table to the all tables created so far but for the
BONUS table.
EMPLOYEE TABLE
EMPNO ENAME JOB MGR HIRE SALARY COMM DEPTNO
DATE*
1111 Manohar Arya PROJ-MGR 88000 99000 110
1112 Raashi Sharma DEVELOPER 1115 21760 0 120
1113 Shabana Parveen SR. 1121 26780 17600 130
DEVELOPER
1114 Indrani S TEST 1111 21970 110
1115 Sudhir Prasad PROJ-MGR 68000 22000 120
1116 Bhaskar Rao ARCHITECT 1115 56000 12000 120
1117 Srikanta M S TEST 1111 23450 0 110
1118 Satish Naik LEAD TEST 1111 31800 15000 110
1119 Meera Raghavan PROJ.LEAD 1115 47000 34000 120
1120 Vijaya C K SR. 1115 32800 23980 120
DEVELOPER
1121 Dipesh Mehta PROJ-MGR 78000 46890 130
1122 Arun Chawla TEST 1115 24500 0 120
1123 Piyush Patel PROJ.LEAD 1111 38000 22000 110
1124 G Rajashekhar LEAD TEST 1115 32000 19750 120
1125 Ganesh D ARCHITECT 1121 31000 130
1126 Amir Ali LEAD TEST 1121 34560 18770 130
1127 Naveen Paul TEST 1111 22450 0 110
1128 Sonali Mohanty DEVELOPER 1115 23450 0 120
1129 Mohd. Shariff SR. 1121 34560 17000 130
DEVELOPER
1130 Shubhangi Bose LEAD TEST 1111 29000 0 110
* Please enter the HIREDATE less than today’s date for all employees.
SALGRADE
GRADE HISAL LOSAL
A 100000 70001
B 70000 50001
C 50000 28001
D 28000 0
DEPT
DEPTNO DNAME
110 APPL-ENGG
120 REQUIREMENTS-DESIGN
130 TESTING-IMPL
140 GLOBAL-DELIVERY
PROJ
PROJNO PNAME BUDGET LOCATION
1 ABN-AMRO 80.5 MYSORE
2 CITIBANK 110.10 BANGALORE
3 HSBC 150.5 MYSORE
4 ANZ 72.5 BANGALORE
5 TELSTAR 100.00 CHENNAI
Copy rows from EMP table into the BONUS table.
PART-B
EMPNO PROJNO
1111 1
1112 2
1113 3
1114 1
1115 2
1116 2
1117 1
1118 1
1119 2
1120 2
1121 5
1122 2
1123 1
1124 2
1125 5
1126 4
1127 1
1128 2
1129 4
1130 5
28. Join EMP and DEPT and list departments 130 and 140 with or without employees.
29. Display information about employees earning more than any employee in Dept. 130.
30. List employees in Dept. ‘APPL-ENGG’ with the same job as anyone in dept. 130.
31. List employees with either the same job as SHUBHANGI, or as salary greater than or equal to
VIJAYA C K’s in order by job and salary.
32. List employees in dept.110 with the same job as anyone in the TESTING dept.
33. Find all the average salary of employees in their own departments, and list them, in department
order.
34. Display information about employees who have at least one other employee reporting to them.
35. List the name and job of the employees earning the highest salary.
36. List each EMPLOYEE and the PROJECT and LOCATION where they work.
37. Calculate the total compensation for all TEST people.
38. List employees whose commission is greater than 15% of their salary.
39. List developers in descending order of their commission divide by their salary.
40. Calculate total annual compensation of employees who are not managers.
41. Display name, and the greater value of salary or commission.
42. Find the average and total salaries of all PROJECT MANAGERS.
43. Find the highest and lowest salaries and the difference between them.
44. Find the average annual compensation of all appl-engg people.
45. Count the employees who are in TESTING as architects.
46. Count the number of different jobs held by employees in department 130.
47. Count the number of employees not belonging to department 130.
48. List average salary of each department.
49. Find the average maximum salary of the non managerial staff.
50. Display information about all employees who are not eligible to receive commissions.
51. Compute SAL + COMM treating null commissions as zero.
52. Compute years of service for each employee in department 110.
53. List the name and year of hire for each salesperson.
54. Sort the details of employees by job and in the descending sequence of salary.
55. List the locations where the budget for the projects exceeds 75 million.
56. List the employees who are working for the TELSTAR project.
57. List the employees who are in more than one project.
58. List the names of employees who work in locations in the Chennai region.
59. Create a view of EMP that excludes the fields SAL and COMM
60. Create a view joining EMP to PROJ
61. Define a view named PAY which calculates annual salary.
62. Create a view showing testing department employees.
63. Define a view of the employee table that includes only project names and their assignment to
employee.
64. Create an index on column ENAME of table EMP
65. Create a unique index on EMPNO.
66. Find all the employees who earn more than the average salary of employees in their own
departments, and list them, in department order.