Practical 2 Analytical Queries
Practical 2 Analytical Queries
Create tables Employee and Department as per the given schema and insert data
into
them.
dept(deptno number(2,0),dname varchar2(14),loc varchar2(13),constraint pk_dept
primary
key (deptno));
emp(empno number(4,0),ename varchar2(10), job varchar2(9), mgr number(4,0),hiredate
date,sal number(7,2),comm number(7,2),deptno number(2,0), constraint pk_emp primary
key
(empno),constraint fk_deptno foreign key (deptno) references dept (deptno));
Answer:
INSERT INTO emp VALUES (7698, 'BLAKE', 'MANAGER', 7839, TO_DATE('1-5-1981', 'dd-mm-
yyyy'), 2850, NULL, 30);
INSERT INTO emp VALUES (7782, 'CLARK', 'MANAGER', 7839, TO_DATE('9-6-1981', 'dd-mm-
yyyy'), 2450, NULL, 10);
INSERT INTO emp VALUES (7566, 'JONES', 'MANAGER', 7839, TO_DATE('2-4-1981', 'dd-mm-
yyyy'), 2975, NULL, 20);
2. To show us how the average salary has changed over the years
3.To display the salary of each employee, along with the lowest and highest within
their
department
4. To divide the whole result set into five buckets based on salary
5. To display for each employee in Department 30 in the employees table, the hire
date
of the
employee hired just after
Q2. 2. Create the table Sales and insert records as given. Write analytical queries
–
Q.3. The research is about to create the star schema for the sales system. The
research
consists of
all the information related to the sale’s record like items, location and the time
etc.
Create a
schema (database) with fact and dimension tables. Perform the OLAP operations on
your schema.
SELECT *
FROM Sales s
JOIN Time t ON s.time_key = t.time_key
WHERE t.quarter = 1;
2. Display total sales of pen or jeans from “mumbai" or “chennai” for quarter 1 or
2.