Sunteți pe pagina 1din 10

Lab1

Theres a pdf also

Lab 2
Lab 3

Create table and populate the value given and provide solution file

create table dept(

deptnonumber(2,0),

dnamevarchar2(14),

locvarchar2(13),

constraint pk_dept primary key (deptno)

create table emp(

empnonumber(4,0),

enamevarchar2(10),

jobvarchar2(9),

mgrnumber(4,0),
hiredate date,

salnumber(7,2),

commnumber(7,2),

deptnonumber(2,0),

constraint pk_emp primary key (empno),

constraint fk_deptno foreign key (deptno) references dept (deptno)

insert into DEPT (DEPTNO, DNAME, LOC) values(10, 'ACCOUNTING', 'NEW


YORK')

insert into deptvalues(20, 'RESEARCH', 'DALLAS')

insert into deptvalues(30, 'SALES', 'CHICAGO')

insert into deptvalues(40, 'OPERATIONS', 'BOSTON')

insert into empvalues(7839, 'KING', 'PRESIDENT', null,to_date('17-11-


1981','dd-mm-yyyy'),5000, null,10)

insert into empvalues(7698, 'BLAKE', 'MANAGER', 7839,to_date('1-5-


1981','dd-mm-yyyy'),2850, null, 30)

insert into empvalues(7782, 'CLARK', 'MANAGER', 7839,to_date('9-6-


1981','dd-mm-yyyy'),2450, null, 10)

insert into empvalues(7566, 'JONES', 'MANAGER', 7839,to_date('2-4-


1981','dd-mm-yyyy'),2975, null, 20)

insert into empvalues(7788, 'SCOTT', 'ANALYST', 7566,to_date('13-JUL-


87','dd-mm-rr') - 85,3000, null, 20)

insert into empvalues(7902, 'FORD', 'ANALYST', 7566,to_date('3-12-


1981','dd-mm-yyyy'),3000, null, 20 )

insert into empvalues(7369, 'SMITH', 'CLERK', 7902,to_date('17-12-


1980','dd-mm-yyyy'),800, null, 20)
insert into empvalues(7499, 'ALLEN', 'SALESMAN', 7698,to_date('20-2-
1981','dd-mm-yyyy'),1600, 300, 30)

insert into empvalues(7521, 'WARD', 'SALESMAN', 7698,to_date('22-2-


1981','dd-mm-yyyy'),1250, 500, 30)

insert into empvalues(7654, 'MARTIN', 'SALESMAN', 7698,to_date('28-9-


1981','dd-mm-yyyy'),1250, 1400, 30)

insert into empvalues(7844, 'TURNER', 'SALESMAN', 7698,to_date('8-9-


1981','dd-mm-yyyy'),1500, 0, 30)

insert into empvalues(7876, 'ADAMS', 'CLERK', 7788,to_date('13-JUL-87',


'dd-mm-rr') - 51,1100, null, 20)

insert into empvalues(7900, 'JAMES', 'CLERK', 7698,to_date('3-12-


1981','dd-mm-yyyy'),950, null, 30)

insert into empvalues(7934, 'MILLER', 'CLERK', 7782,to_date('23-1-


1982','dd-mm-yyyy'),1300, null, 10)

select ename, dname, job, empno, hiredate, loc

from emp, dept

where emp.deptno = dept.deptno

order by ename

//Simple natural join between DEPT and EMP tables based on the primary
key of the DEPT table DEPTNO, and the DEPTNO foreign key in the EMP
table.

select dname, count(*) count_of_employees

from dept, emp

where dept.deptno = emp.deptno

group by DNAME

order by 2 desc
//The GROUP BY clause in the SQL statement allows aggregate functions of
non grouped columns. The join is an inner join thus departments with no
employees are not displayed.

CREATE TABLE BONUS

ENAME VARCHAR2(10),

JOB VARCHAR2(9),

SAL NUMBER,

COMM NUMBER

CREATE TABLE SALGRADE

( GRADE NUMBER,

LOSAL NUMBER,

HISAL NUMBER )

INSERT INTO SALGRADE VALUES (1,700,1200)

INSERT INTO SALGRADE VALUES (2,1201,1400)

INSERT INTO SALGRADE VALUES (3,1401,2000)

INSERT INTO SALGRADE VALUES (4,2001,3000)

INSERT INTO SALGRADE VALUES (5,3001,9999)

1. Display the dept information from department table

2. Display the details of all employee

3. display the name and job for all employee

4. display name and salary for all employee

5. display employee number and total salary for each employee


6. display employee name and anual salary for all employee

7. display the names of all employee who are working in department number
10

8. display the names of all employee working as clerks and drawing a salary
more than 3000

9. display employee number and names for employee who earns commission

10. display names of employee who do not earn any commission

11. display the names of employee who are working as clerk, salseman or
analyyst and drawimg a salary more than 3000

12. display the names of employee who are working in company for the past
5 years

13. display the list of employee who have joines the company before 30 june
90 or after 31 dec 90

14. display the names of employee working in department number 10 or 20


0r 40 or employee working as clerks, salseman or analyst

15. display names of employee whose name starts with alphabet S

16. display names of employee whose name ends with alphabet S

17. display the names of employee whose names have second alphabet A in
their names

18. display the names of employee whose name is exactly five charactere in
length

19. display the total number of employee working in the company

20. display the total salary being paid to all employee

21. display the maximum salary from emp table

22. display minimum salary from emp table

23. display the average salary from emp table

24. display the maximum salary being paid to clerk


25. display the maximum salary being paid in dept no 20

26. display the min salary being paid to any salseman

27. display the average salary drawn by manager

28. display the names of employee in order of salary i.e the name of the
employee earning lowest salary should appear first

29. display the names of employees in descending order of salary

30. display the details from emp table in order of emp name

31. display empno ename deptno and sal. sort the output first based on
name and within name by deptno and within deptno by sal

32. display the name of the employee along with their annual salary
(sal*12) the name of the employee earning highest annual salary should
appear first

33. display name, sal, hra, pf, da, total sal for each employee. the output
shouldbe in the order oftotal sal, hra 15% of sal,da 10% of sal, pf 5%of sal
total salary will be (sal*hra*da)-pf

34. display dept number and total number of employees within each group

35. display the various jobs and total number of employee with each job
group

36. display department number and total salary for each department

37. display department number and maximum salary for each depatrment

38. display the various jobs and total salary for each job

39. display each job along with minimum sal being paid in each job group

40. display the department numbers with more than three employee in each
dept

41. display the various jobs along with total sal for each of the jobswhere
total sal is greater than 40000
41. display the various jobs along with total number of employee in each
job. the output should contain only those jobs with more than three
employee

42. display the name of emp who earns highest sal

43. display the employee number and name of employee working as cleark
and earning highest salary among clerks

44. display the names of clearkwho earn salary more than that of james of
that of sal lesser than that of scott

45. display names of employees who earns a sal more than that of james or
that of salary greater than that of scott

Lab 4

Consider the Inventory Processing System of ARISTO Company. Items are


received from suppliers; tested for acceptance and only the good are stores
in the stock room. When the items are requested by the production
departments, if sufficient quantity is available, they are issued; else,
whatever is available on hand is only issued. When an item is received or
issued, quantity on hand is suitably modified. The Inventory database is to
contain the following tables:

Stock (Item_Code, Item_Name, Unit_price, Qty_on_hand)

Receipts (Item_Code, Receipt_Code, Recd_Date, Recd_Qty, Supplier,


Qty_Accepted)

Issues (Item_Code, Issue_Code, Issued_Date, Dept, Qty_Requested)

1.Create the tables in the Inventory database in Oracle and populate them
using the data given in Inventory_Mngt_create file

2.Validate the following by adding a check constraint while creating the table.
a)Accepted quantity cannot be above Received quantity
b)Received quantity cannot fall below 10

3.Write SQL queries for the following:


a.Retrieve the Code and Name of all the items and their suppliers
which are tested and accepted fully when they are received from
suppliers.
b.Get the total Inventory cost of all items stocked (Hint: For every
item in stock total the unit price * quantity on hand)

What to Deliver?

1.%_soln.txt file showing solution for problems 1, 2a, 2b, 3a, 3b

Note:

% is your Registration number

Theres a pdf

Lab 5

S-ar putea să vă placă și