Create Table EmpData
Create Table EmpData
HireDate date, Spouse varchar(10), WHAllowance int, BenPlanId int, foreign key (BenPlanId)
references Benifits(BenPlanId) );
create table Benifits (BenPlanId int primary key, PlanName varchar(10), BaseCost int, SpouseCost
int);
create table Department (DeptId int primary key, Dept varchar(10), Title varchar(10), Grade char);
create table Work (WorkId int primary key, PayRate int, Salaried varchar(3), EmpId int, DeptId int ,
foreign key (EmpId) references EmpData(EmpId), foreign key (DeptId) references
Department(DeptId) );
-- ++++++++++++++++++++++++++++++++
-- ===================================
insert into EmpData values (202, "Ish", "Kale", "2022-11-18", "-", 1, 102);
insert into EmpData values (203, "Shubham", "Jadhav", "2022-12-19", "-", 2, 103);
insert into EmpData values (204, "Suraj", "Jedhe", "2022-10-14", "-", 3, 101);
insert into EmpData values (205, "Saurav", "Mane", "2022-12-8", "-", 1, 102);
insert into EmpData values (206, "Megha", "Giri", "2022-12-8", "Someone", 1, 104);
-- ===================================
-- ==============================
-- ==================================
use upthink;
-- ==================================
-- =================================
if((WHAllowance = 1), 0.33, if((WhAllowance = 2), 0.25, if((WhAllowance = 3), 0.17, if((WhAllowance
= 4), 0.11, 0.08)))) As TaxRate, PayRate
From EmpData
On EmpData.BenPlanId = Benifits.BenPlanId
right join
Work
on
EmpData.EmpId = Work.EmpId
union
if((WHAllowance = 1), 0.33, if((WhAllowance = 2), 0.25, if((WhAllowance = 3), 0.17, if((WhAllowance
= 4), 0.11, 0.08)))) As TaxRate, PayRate
From EmpData
left join Benifits
On EmpData.BenPlanId = Benifits.BenPlanId
left join
Work
on
EmpData.EmpId = Work.EmpId
);
-- =====================================
if((WHAllowance = 1), 0.33, if((WhAllowance = 2), 0.25, if((WhAllowance = 3), 0.17, if((WhAllowance
= 4), 0.11, 0.08)))) As TaxRate, PayRate
From EmpData
On EmpData.BenPlanId = Benifits.BenPlanId
right join
Work
on
EmpData.EmpId = Work.EmpId
union
if((WHAllowance = 1), 0.33, if((WhAllowance = 2), 0.25, if((WhAllowance = 3), 0.17, if((WhAllowance
= 4), 0.11, 0.08)))) As TaxRate, PayRate
From EmpData
On EmpData.BenPlanId = Benifits.BenPlanId
left join
Work
on
EmpData.EmpId = Work.EmpId
);