Daatabasemgmtassignment 1
Daatabasemgmtassignment 1
Daatabasemgmtassignment 1
Table created.
EMP_NAME VARCHAR2(30)
DESIGNATION VARCHAR2(10)
DATE_OF_JOIN DATE
SALARY NUMBER
DEPT_NO NUMBER(11)
30),dept_loc varchar(20));
Table created.
DEPT_NAME VARCHAR2(30)
DEPT_LOC VARCHAR2(20)
conveyance number);
Table created.
SP_ALLOWANCE_007 NUMBER
CONVEYANCE NUMBER
2 values(&emp_no,&emp_name,&designation,&date_of_join,&salary,&dept_no);
old 2: values(&emp_no,&emp_name,&designation,&date_of_join,&salary,&dept_no)
new 2: values(1000,'robert','officer','01-dec-1985',1000,10)
1 row created.
SQL> /
old 2: values(&emp_no,&emp_name,&designation,&date_of_join,&salary,&dept_no)
new 2: values(10002,'allan','clerk','14-may-1982',5000,10)
1 row created.
SQL> /
old 2: values(&emp_no,&emp_name,&designation,&date_of_join,&salary,&dept_no)
new 2: values(10003,'martin','manager','23-dec-1984',3500,20)
1 row created.
SQL> /
old 2: values(&emp_no,&emp_name,&designation,&date_of_join,&salary,&dept_no)
new 2: values(10004,'james','analyst','22-jul-1990',5000,30)
1 row created.
SQL> /
old 2: values(&emp_no,&emp_name,&designation,&date_of_join,&salary,&dept_no)
new 2: values(10005,'john','analyst','22-jul-1990',4900,30)
1 row created.
SQL> /
old 2: values(&emp_no,&emp_name,&designation,&date_of_join,&salary,&dept_no)
new 2: values(10006,'jones','clerk','16-apr-1986',950,30)
1 row created.
1 row created.
1 row created.
SQL> /
1 row created.
SQL> /
1 row created.
SQL> /
1 row created.
SQL> /
1 row created.
1 row created.
SQL> /
1 row created.
SQL> /
1 row created.
SQL> /
1 row created.
Connected.
6 rows selected.
10 marketing london
20 accounts america
40 software boston
50 production boston
----------------------------------------------------------------------------------------------------------------
Q2.LIST THE EMPLOYEES WHO ARE EARNING MORE THEN 1200 BUT LESS THAN 4000.
SQL> select * from employee_007 where salary between 1200 and 4000;
-----------------------------------------------------------------------------------------------------------
Q3. List the employees who have joined after 1st jan 1984 in order of the joining date.
_join;
-----------------------------------------------------------------------------------------------------
ger');
EMP_NO EMP_NAME DESIGNATIO DATE_OF_JOIN SALARY DEPT_NO
-------------------------------------------------------------------------------------------------------
s';
DEPT_NO DEPT_NAME
---------- ------------------------------
40 software
50 production
SQL> select * from employee_007 where salary >(select salary from employee_007 w
here emp_name='robert');
-------------------------------------------------------------------------------------------------
COUNT(*)
----------
6
Q10. Find how many employees are working in sales department
COUNT(*)
----------
llowance_007.designation;
SUM(EMPLOYEE_007.SALARY+ALLOWANCE_007.SP_ALLOWANCE_007+ALLOWAN
CE_007.CONVEYANCE)
--------------------------------------------------------------------------------
28050
llowance_007.designation;
AVG(EMPLOYEE_007.SALARY+ALLOWANCE_007.SP_ALLOWANCE_007+ALLOWAN
CE_007.CONVEYANCE)
--------------------------------------------------------------------------------
4675
MIN(EMPLOYEE_007.SALARY+ALLOWANCE_007.SP_ALLOWANCE_007+ALLOWAN
CE_007.CONVEYANCE)
--------------------------------------------------------------------------------
1750
EMP_NAME DESIGNATIO G
------------------------------ ---------- -
robert officer B
allan clerk D
martin manager A
james analyst C
john analyst C
jones clerk D
6 rows selected.
Q15.display employee names and date of join ,joining date should be in the format
’26,january1998’.
employee_007;
EMP_NAME DATE_OF_JOIN
------------------------------ -----------------
6 rows selected.
TOTAL_SALARY
------------
15050
5000
8000
Q18.display the maximum salaries in each department. Along with the name of the department.
SQL> select department_007.dept_name,max(salary) from department_007,employee_00
DEPT_NAME MAX(SALARY)
------------------------------ -----------
accounts 3500
sales 5000
marketing 5000
EMP_NAME TOTAL_SALARY
------------------------------ ------------
allan 5200
robert 1400
james 5700
john 5600
jones 1150
martin 4000
6 rows selected.
Q20 give the details of employee with the second highest salary.
DEPT_NO
----------
30