Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

SQL> create table Employees(

2 employee_id number(6),

3 first_name varchar2(25),

4 last_name varchar2(25),

5 hire_data date,

6 dept_no number(6),

7 constraint employee_pk primary key(employee_id));

Table created.

SQL> create table department(

2 dept_no number(6),

3 dept_name varchar2(25),

4 constraint department_pk primary key(dept_no));

Table created.

SQL> create table salary(

2 employee_id number(6),

3 salary number,

4 tax number,

5 bonus number,

6 acc_no number,

7 foreign key(employee_id) references Employees(employee_id));

Table created.

SQL> alter table Employees

2 add leaves_no number;

Table altered.

SQL> alter table salary

2 add sal_cut number;


Table altered.

SQL> create table Leave(

2 dept_no number(6),

3 sick_leaves number,

4 casual_leaves number,

5 paid_leaves number,

6 foreign key(dept_no)references department(dept_no));

Table created.

SQL> create table accdetails(

2 employee_id number(6),

3 acc_id number,

4 bank_name varchar2(35),

5 acc_number number,

6 constraint accdetails_pk primary key(acc_id),

7 foreign key(employee_id) references Employees(Employee_id));

Table created.
select first_name,last_name,case when leaves_no>(sick_leaves+casual_leaves+paid_leaves) then
'Leaves exceeded' when leaves_no=(sick_leaves+casual_leaves+paid_leaves) then 'No Leaves left'
else 'Leaves available' end as Leaves_status from Employees e join Leave l on e.dept_no=l.dept_no;
select employee_id,first_name,last_name, dept_name from Employees e join department d on
e.dept_no=d.dept_no;

select max(salary) as highest_salary from Salary;

You might also like