You are on page 1of 9

MAHNOOR ZAHID BSEF17M507

POST MIDSS LAB-1:

TASK 1
Show Company name and decode location
If location is gujranwala, place 1 in result
If location is islamabad , place 2 in result
Else place 0 in result

SELECT
COMPANYNAME,CITY,DECODE(CITY,'GUJRANWALA',1,'ISLAMABAD',2,0) AS
“RESULT”

FROM COMPANY;

TASK 2
Show pack id,speed,monthly payment,and tax applied on monthly payment using the following
criteria
5 % increase If pack id is 1,
12 % increase If pack id is 6 ,
15 % increase If pack id is 2,
20 % increase If pack id is 7,
50 % increase If pack id is 5,
30 % increase If pack id is 8
AND order by Sector Number.
SELECT PID, SPEED, MONPAYMENT,

DECODE(PID,

1,0.05*MONPAYMENT,

6,0.12*MONPAYMENT,

2,0.15*MONPAYMENT,

7,0.20*MONPAYMENT,

5,0.50*MONPAYMENT,

8,0.30*MONPAYMENT) "TAX"

FROM PACKAGE

ORDER BY SID

TASK 3
Show employee name, his company name, old salary and increased salary for the following
criteria:
10% increase IF company name is ‘APPLE’,
50% increase IF company name is ‘FIRST BANK CORPORATION’, 40% increase IF company name is
‘SMALL BANK CORPORATION’,
100% increase IF company name is ‘HBL’,
And same salary for the remaining companies.
Order by new salaries in ascending order.
SELECT EMPNAME, COMPANYNAME, SALARY "OLD SALARY",

DECODE(COMPANYNAME,'APPLE', 1.1*SALARY,

'FIRST BANK CORPORATION', 1.5*SALARY,

'SMALL BANK CORPORATION', 1.4*SALARY,

'HBL', 2*SALARY,SALARY) AS "INCREASED SALARY"

FROM WORKS

ORDER BY "INCREASED SALARY"

TASK 4
Give EMPLOYEE NAME , COMPANY NAME and SALARY as “Incremented Salary” with these
conditions:
If the company name is FIIRSTBANKCORPORATION’, add 20% to salary.
If the company name is ‘SARTE’, add 30% to salary.
If the company name is‘LARGEBANKCORPORATION’, add 60% to salary.
If the company name is ‘SMALLBANKCORPORATION’, add 40% to salary.
If the company name is ‘BINYAPI’, add 90% to salary
SELECT EMPNAME,COMPANYNAME,

DECODE (COMPANYNAME,

'FIIRST BANK CORPORATION',1.2*SALARY,

'SARTE',1.3*SALARY,

'LARGE BANK CORPORATION',1.6*SALARY,

'SMALL BANK CORPORATION',1.4*SALARY,

'BINYAPI',1.9*SALARY

) "INCREMENTED SALARY"

FROM WORKS

TASK 5
Show employee name and job name on the basis of salary WHEN salary>100000 THEN 'Manager'
WHEN salary between 50000 and 100000 THEN 'Co manager'
WHEN salary between 25000 and 40000 THEN 'Planer'
WHEN salary between 15000 and 24000 then 'Employee'
ELSE 'intern'
SELECT EMPNAME,

CASE

WHEN SALARY>100000 THEN 'Manager'

WHEN SALART BETWEEN 50000 and 100000 THEN 'Co manager'

WHEN SALARY BETWEEN 25000 and 40000 THEN 'Planer'

WHEN SALARY BETWEEN 15000 and 24000 THEN 'Employee'

ELSE 'intern'

END AS "JOBS"

FROM WORKS

TASK 6
Display names of employees and annual bonus as
“Bonus” based on the following criteria:
1. If employee works for ‘First Bank Corp’, bonus is 30% of
annual salary.
2. If employee works for ‘Second Bank Corp’, bonus is 20% of
annual salary.
3. If employee works for ‘Small Bank Corp’, bonus is 5% of
annual salary.
SELECT EMPNAME,

DECODE(COMPANYNAME,

'FIRST BANK CORPORATION', 0.3*(SALARY*12),

'SECOND BANK CORPORATION', 0.2*(SALARY*12),

'SMALL BANK CORPORATION', 0.05*(SALARY*12)

) "BONUS"

FROM WORKS

TASK 7
DISPLAY EMPLOYEE RANKS WITH RESPECT TO THEIR SALARIES I.E.,
If the employee's salary is between 0 to 8100 , rank as JUNIOR.
If the employee's salary is between 8100 to 9200 , rank as SENIOR.
If the employee's salary is between 9200 to 12000 , rank as MANAGER
If the employee's salary is between 12000 to 17100 , rank as SUPERVISOR.
SELECT

CASE

WHEN SALARY BETWEEN 0 AND 8100 THEN 'JUNIOR'

WHEN SALARY BETWEEN 8100 AND 9200 THEN 'SENIOR'

WHEN SALARY BETWEEN 9200 AND 12000 THEN 'MANAGER'

WHEN SALARY BETWEEN 12000 AND 17100 THEN 'SUPERVISOR'

END AS "RANKS"

FROM WORKS

TASK 8
Give name,city,incremented salary of all employees depending to their managers and company
names
Incremented values: if manager is FAZEEL increment 10% in salary
if manager is SAQLAIN increment 15% in salary
if manager is AHMAD increment 20% in salary

if manager is SHAHAB increment 12% in salary


SELECT E.EMPNAME, E.CITY,

DECODE(M.EMPNAME,

'FAZEEL',1.1*W.SALARY,

'SAQLAIN',1.15*W.SALARY,

'AHMAD', 1.2*SALARY,

'SHAHAB', 1.12*SALARY

) "INCREASED SALARY"

FROM EMPLOYEE E, WORKS W, MANAGERS M

WHERE E.EMPNAME=W.EMPNAME

AND E.EMPNAME=M.EMPNAME

TASK 9
Show employee name company name and salary of all employees in database
If company name is FIRST Bank Corporation’ then deduct 5% from salary.
If company name is smart bank corporation’ then deduct 10% from salary.
If company name is ‘small bank corporation’ then deduct 15% from salary.
If company name is ‘brads drink’ then deduct 17% from salary.
If company name is ‘apple computer’ then deduct 20% from salary.
SELECT EMPNAME, COMPANYNAME,

DECODE(COMPANYNAME,

'FIRST BANK CORPORATION', SALARY - 0.05*SALARY,

'SMART BANK CORPORATION', SALARY - 0.1*SALARY,

'SMALL BANK CORPORATION', SALARY - 0.15*SALARY,

'BRADS DRINK', SALARY - 0.17*SALARY,

'APPLE COMPUTER', SALARY - 0.20*SALARY

) "DEDUCTED SALARY"

FROM WORKS

You might also like