iSelfSchooling.com - Copyright © 1999-2009 iSelfSchooling.com ||  References  |  Job Openings
    Home  | Search more...  |  FREE Online VIDEO Oracle Training 

    Oracle Syntax  | Suggestions  | Private Tutoring

  Copyright & User Agreement

Email2aFriend  | Homepage us! |  Bookmark

Services

 Vision/Mission

 Services

 Biography

 Contact Us

 FREE Training

 SQL

 PL/SQL

 Forms 

 Reports

 Other TOOLS

 Fundamentals

 Performance

 OEM

 Application Server

 Grid Control

 Articles

 Prepare for OCP

Oracle SYNTAX

 Oracle Functions

 Oracle Syntax

 Oracle 10g Syntax

  PL/SQL Syntax

UNIX and more...

 UNIX for DBAs

 LINUX for DBAs

 DB using PHP

  A+ Certification

 Basics of JAVA  

 Tips of  SEO

Finance/Jobs

 Financial Aid

 Skilled

 Oracle

 Jobs

  Magazine

More Training

 Q & Answers

 SQL-PL/SQL

 DBA

 Developer

 Important Notes

 Case Studies

 9i New Features

 10g New Features

 10g Qs/As

 Grid Control

 OracleAS # I

 OracleAS # II

  LDAP and OID

  HTTP Server

 Instructor-Led

  Virtual Hosts

 Community Sharing

More to know...

Acknowledgement**

 FREE Legal Forms

 Who is who

 Market Place

 University Directory

 Advisory Articles

 Links...

 

 

Topics:  Hands-On 06

 

Data warehousing is a focus in your organization. Management needs more reports in order to truly understand their data. You have been assigned to write simple SQL statement using the “ROLLUP” operator to create salary subtotals for each type of job per year. Also, you should use the CUBE operator to enable a simple statement to calculate all possible combinations of the types of jobs and year for the research department only.

 

Notice: A select statement using the ROLLUP operator returns both ‘regular rows’ and ‘super-aggregate rows.’ Super-aggregate rows are rows that contain a sub-total value.

 

A select statement using the CUBE operator returns cross-tabulation values, thus produces totals in all possible dimensions, and is used for warehousing aggregated data reports.

 

More Resources by Google:

Manuscript

-- Hands-On 06 (Data Warehousing - rollup and cube function) 

CLEAR SCR 
SET ECHO ON 
-- Connect to SQL*PLUS as the iself user.
--
pause

CONNECT iself/schooling
pause

CLEAR SCR
-- Set the pagesize to 55 and the linesize to 100.
--
pause

SET PAGESIZE 55
SET LINESIZE 100
pause

CLEAR SCR
-- Alter the EMP table, and add a column
-- to store the year that employees were
-- hired.
-- 
pause

ALTER TABLE emp ADD (year VARCHAR2(2))
/
pause

CLEAR SCR
-- Set the column year heading.
--
pause

COLUMN year FORMAT a4 HEADING "Year"
pause

CLEAR SCR
-- Update the EMP table to set the year each employee
-- was hired, into the newly created YEAR column.
--
pause

UPDATE emp 
SET year = TO_CHAR(hiredate,'YY') 

commit;
pause

CLEAR SCR
-- Query an aggregation sum report for each job, 
-- in each year, using the ROLLUP grouping option.
pause

SELECT year, job, SUM(sal), COUNT(*) 
FROM emp 
GROUP BY ROLLUP (year, job)
/
-- This is an example of a GROUP BY ROLLUP option.
pause 

CLEAR SCR
-- Query an aggregation sum report for 
-- each job, in each year using the CUBE option group
-- for the research department only.
pause

SELECT year, job, SUM(sal), COUNT(*) 
FROM emp 
WHERE deptno = 20
GROUP BY CUBE (year, job)
/
-- This is an example of a GROUP BY CUBE option.
pause

CLEAR SCR
-- Drop the year column

pause

ALTER TABLE emp DROP (year)
/
-- You have dropped the year column so that you can
-- perform this excercise over and over again.
pause

CLEAR SCR
-- Now, practice this Hands-On over and over
-- until you become a master at it.

-- For more information about the subject, you are encouraged
-- to read from a wide selection of available books.

-- Good luck!
pause

 

 
 
Google
 
Web web site