100% found this document useful (1 vote)
197 views

Create Database PMS

The document creates a database called PMS and defines tables to store employee, company, and payroll information. It inserts sample data and defines a function to calculate tax based on salary. Finally, it runs queries to select data from the payroll table including calculated tax, pension, total deductions, and net pay.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
197 views

Create Database PMS

The document creates a database called PMS and defines tables to store employee, company, and payroll information. It inserts sample data and defines a function to calculate tax based on salary. Finally, it runs queries to select data from the payroll table including calculated tax, pension, total deductions, and net pay.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

create database PMS

use PMS
create table Employee_teb
(EmpID varchar(50) primary key,
Emp_Fname varchar(50),
Emo_Lname varchar(50),
Sex varchar(5),
Address varchar(50),
Phone int,
Email varchar(50),
CID varchar(50) foreign key references Canpany (CID)
)

create table Canpany


(CID varchar(50) primary key,
C_name varchar(50),
Location varchar(50),
Phone int,
Email varchar(50),)

create table Peroll


(PID varchar(50) primary key,
EmpID varchar(50) foreign key references Employee_teb (EmpID) unique not
null,
Position varchar(50),
salary int,)
insert into Canpany
values('C001','MGMBPTC','Holata',01153450,'MGMBPTC@gmail.com')
select *from Canpany
select *from Employee_teb
select *from Peroll

insert into Employee_teb


values('E001','Meles','seid','M','Holata',97735562,'ME@gmail.com','C001')

insert into Peroll values('P001','E001','Sec',5000)

create function CalculateTax(@sal int)


returns float
as
begin
declare @tax float
if @sal<=150
set @tax=0
else if @sal<=151
set @tax=(@sal*.1)-3.75
else if @sal<=206.25
set @tax=(@sal*.1)-7.5
else if @sal<=412.50
set @tax=(@sal*.1)-15
else if @sal<=825
set @tax=(@sal*.1)-30
else if @sal<=1650
set @tax=(@sal*.1)-60
else if @sal<3200
set @tax=(0.15*@sal)-142
else if @sal<=5250
set @tax=(0.25*@sal)-302
else if @sal<=7800
set @tax =(0.25*@sal)-565
else if @sal<=10900
set @tax=(0.3*@sal)-955
else if @sal>10900
set @tax=(0.35*@sal)-1500
return @tax
end
select PID,EmpID,Position,salary,dbo.CalculateTax(Peroll.salary) as Tax from
Peroll

select PID,EmpID,Position,salary,dbo.CalculateTax(Peroll.salary)as
Tax,salary*.07 as pession from Peroll

select PID,EmpID,Position,salary,dbo.CalculateTax(Peroll.salary)as
Tax,salary*.07 as pession,
dbo.CalculateTax(Peroll.salary)+salary*.07 as total_dudaction from Peroll

select PID,EmpID,Position,salary,dbo.CalculateTax(Peroll.salary)as
Tax,salary*.07 as pession,
dbo.CalculateTax(Peroll.salary)+salary*.07 as total_dudaction,
salary-(dbo.CalculateTax(Peroll.salary)+salary*.07) as natpay from Peroll

You might also like