You are on page 1of 2

--Assignment:

--
--1) write a program to display the total salary i am paying
-- to deptno 30 employees?
/
DECLARE
l_deptno char(2);
l_ssal number(7,2);
BEGIN
l_deptno:=&l_deptno;
select sum(sal) into l_ssal from emp where deptno=l_deptno;
dbms_output.put_line(l_ssal);
END;
/
select *from emp;
/
--2) write a program to display the "number of male
--customers" from the given city?
select *from cust_dtls;
declare
l_ct varchar2(5);
l_gender char(2);
begin
l_ct:='&l_ct';
select count(*) into l_gender from cust_dtls where gender='M' AND CITY=l_ct;
dbms_output.put_line('the number of male customers in ' ||l_ct || ' is ' ||
l_gender);
end;--valid
--3) Write a program to display the number of emps
--working under given deptno?
/
declare
l_deptno number(10);
l_emps char(2);
begin
l_deptno:=&l_deptno;
select count(*) into l_emps from emp where deptno=l_deptno;
dbms_output.put_line('the number of employees in the '|| l_deptno ||'th
department is : ' ||l_emps);
end;--valid
/
--4) write a program to find the number of emps
-- working with given designition?
declare
l_job varchar2(10);
l_count char(5);
begin
l_job:='&l_job';
select COUNT(*) into l_count from emp where job=l_job;
DBMS_OUTPUT.PUT_LINE('THE NUMBER OF EMPLOYEES WORKING UNDER '|| l_job|| ' IS : '
||l_count);
end;--VALID
--5) Write a program to find and display total salary
-- paying to given dept name?
/
declare
l_sal number(7,2);
l_DNAME varchar2(10);
begin
l_DNAME:='&l_DNAME';
select sum(sal) INTO l_sal from emp where DEPTNO=(SELECT DEPTNO FROM DEPT WHERE
DNAME=l_DNAME);
--DBMS_OUTPUT.PUT_LINE('THE TOTAL SALARY PAYING TO ' || l_job || ' IS : ' ||
L_SAL);
end;

You might also like