Copyright: Silberschatz, Korth and Sudarshan 1 OLAP Functions Order-Dependent Aggregates and Windows in SQL: SQL:2003---same as SQL:1999.

Slides:



Advertisements
Similar presentations
5.1Database System Concepts - 6 th Edition Chapter 5: Advanced SQL Advanced Aggregation Features OLAP.
Advertisements

Data Warehouses These slides are a modified version of the slides of the book “Database System Concepts” (Chapter 18), 5th Ed., McGraw-Hill, by Silberschatz,
Econometric Details -- the market model Assume that asset returns are jointly multivariate normal and independently and identically distributed through.
Database System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 18: Data Analysis and Mining.
QUANTITATIVE DATA ANALYSIS
the Sample Correlation Coefficient
Chapter 18: Data Analysis and Mining Chapter 18: Data Analysis and Mining Decision Support Systems Data Analysis and OLAP Data Warehousing Data.
1 1 Data Warehousing Decision-Support Systems  Data Analysis  OLAP  Extended aggregation features in SQL –Windowing and ranking  Implementation Techniques.
Chapter 18: Data Analysis and Mining
©Silberschatz, Korth and Sudarshan22.1Database System Concepts 4 th Edition 1 SQL:1999 Advanced Querying Decision-Support Systems Data Warehousing Data.
©Silberschatz, Korth and Sudarshan22.1Database System Concepts 4 th Edition 1 Extended Aggregation SQL-92 aggregation quite limited  Many useful aggregates.
Basic Practice of Statistics - 3rd Edition
©Silberschatz, Korth and Sudarshan22.1Database System Concepts 4 th Edition 1 Chapter 22: Advanced Querying and Information Retrieval Decision-Support.
Enhancements to the GROUP BY Clause Fresher Learning Program January, 2012.
Database System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 18: Data Analysis and Mining.
1. Data Analysis and Mining 2 Decision Support Systems Data Analysis and OLAP Data Warehousing Data Mining.
Computing & Information Sciences Kansas State University Tuesday, 01 May 2007CIS 560: Database System Concepts Lecture 41 of 42 Tuesday, 01 May 2007 William.
Chapter 22: Advanced Querying and Information Retrieval
Economics 173 Business Statistics Lecture 2 Fall, 2001 Professor J. Petry
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 1: Introduction.
©Silberschatz, Korth and Sudarshan4.1Database System Concepts Chapter 4: SQL Basic Structure Set Operations Aggregate Functions Null Values Nested Subqueries.
Database System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 18: Data Analysis and Mining.
ADVANCE T-SQL: WINDOW FUNCTIONS Rahman Wehelie 7/16/2013 ITC 226.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts - 5 th Edition, Oct 5, 2006 Outer Join n An extension of the join operation that avoids loss.
Computing & Information Sciences Kansas State University Monday, 26 Nov 2007CIS 560: Database System Concepts Lecture 37 of 42 Monday, 26 November 2007.
Review of Measures of Central Tendency, Dispersion & Association
Oracle Analytic Functions for IR Analysis and Reporting Mingguang Xu and Denise Gardner Office of Institutional Research University of Georgia.
©Silberschatz, Korth and Sudarshan18.1Database System Concepts - 5 th Edition, Aug 26, 2005 Extended Aggregation in SQL:1999 The cube operation computes.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com ICOM 5016 – Introduction.
Computing & Information Sciences Kansas State University Wednesday, 12 Nov 2008CIS 560: Database System Concepts Lecture 31 of 42 Wednesday, 12 November.
Summary of introduced statistical terms and concepts mean Variance & standard deviation covariance & correlation Describes/measures average conditions.
Database System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 18: Data Analysis and Mining.
Computing & Information Sciences Kansas State University Wednesday, 29 Nov 2006CIS 560: Database System Concepts Lecture 39 of 42 Wednesday, 29 November.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts - 5 th Edition, Oct 5, 2006 Example.
Chapter 3: Averages and Variation Section 2: Measures of Dispersion.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Introduction.
Decision support, data mining & data warehousing.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Module B: Advanced SQL.
Data warehousing, data analysis and OLAP Sunita Sarawagi
Computing & Information Sciences Kansas State University Thursday, 03 May 2007CIS 560: Database System Concepts Lecture 42 of 42 Thursday, 03 May 2007.
© Jalal Kawash Database Queries Peeking into Computer Science.
Decision support, data mining & data warehousing.
CHAPTER 2: Basic Summary Statistics
Decision support, data mining & data warehousing.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
©Silberschatz, Korth and Sudarshan5.1Database System Concepts - 6 th Edition Recursive Queries.
A Glance at the Window Functions. Window Functions Introduced in SQL 2005 Enhanced in SQL 2012 So-called because they operate on a defined portion of.
Data Preprocessing: Data Reduction Techniques Compiled By: Umair Yaqub Lecturer Govt. Murray College Sialkot.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
Data Analysis Decision Support Systems Data Analysis and OLAP Data Warehousing.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation OLAP Queries and SQL:1999.
Lecturer : Dr. Pavle Mogin
Data Mining: Concepts and Techniques
Database Systems Subqueries, Aggregation
Advanced Teradata SQL GLOBAL Temporary Vs VOLATILE Temporary Vs Derived tables WITH and WITH BY Special Index function Trigger Online Analytical Function.
Chapter 5: Advanced SQL Database System concepts,6th Ed.
Using Window Ranking, Offset, and Aggregate Functions
I WANT TO HOLD YOUR HAND 1ST TOP 100 SINGLE
T-SQL Window Function Deep Dive part 1
Oracle8i Analytical SQL Features
Introduction to Window Functions
Introduction to T-sql Window functionS
CS240B, Winter 2017 Task 2.1:  Using a syntax based on that of notes and the two references above, express a user-defined aggregate d_count to perform.
CS240B: Assignment1 Winter 2016.
Data Warehousing Decision-Support Systems
CHAPTER 2: Basic Summary Statistics
OLAP Functions Order-Dependent Aggregates and Windows in SQL: SQL: same as SQL:1999.
Presentation transcript:

Copyright: Silberschatz, Korth and Sudarshan 1 OLAP Functions Order-Dependent Aggregates and Windows in SQL: SQL: same as SQL:1999

©Silberschatz, Korth and Sudarshan22.2Database System Concepts 4 th Edition 2 Extended Aggregation: OLAP Functions Rank, row_number and other functions based on explicit order Many new statistical functions: see, e.g., DB2 UDB's High-Function Business Intelligence in e-business---Red Book  VAR(X): variance, STDDEV(X): its square root  COV(X,Y): covariance is themeasure of the linear association between two variables.  CORR(X,Y): correlation is normalized covariance. +1 max correlation, 0 none, -1 inverse  Regression functions: Y = a X + b  REGR_SLOPE (X) -> a  REGR_INTERCEPT (X) -> b More: Chi-squared testing, sampling

©Silberschatz, Korth and Sudarshan22.3Database System Concepts 4 th Edition 3 OLAP Functions Windows on aggregates:  Physical windows: based on the number of rows in the window  Logical windows: based on the value span of the window.

©Silberschatz, Korth and Sudarshan22.4Database System Concepts 4 th Edition 4 Ranking Ranking is done in conjunction with an order by specification. Suppose we are given a relation student-marks(Name, marks) which stores the marks obtained by each student. The following query gives the rank of each student. Select Name, rank ( ) (order by (marks) desc) as s-rank, dense_dank ( ) (order by (marks) desc) as s-rank from student-marks order by s-rank Name MarksRank DenseRank Tom Jeff Mary Alex 6 4 3

©Silberschatz, Korth and Sudarshan22.5Database System Concepts 4 th Edition 5 Partition By Ranking can be done within partition of the data. The following query then gives the rank of students within each section: student-marks(student-id, marks); student- section(student-id, section) select student-id, section, rank( ) over (partition by section order by marks desc) as sec-rank from student-marks, student-section where student-marks.student-id = student-section.student-id order by section, sec-rank dense_rank(): no holes after ties row_number(): provide row numbering given a specific partitioning and ordering of rows.

©Silberschatz, Korth and Sudarshan22.6Database System Concepts 4 th Edition 6 Ranking (Cont.) For a given constant n, the ranking the function ntile(n) takes the tuples in each partition in the specified order, and divides them into n buckets with equal numbers of tuples. For instance, we sort employees by salary, and use ntile(3) to find which range (bottom third, middle third, or top third) each employee is in, and compute the total salary earned by employees in each range: select threetile, sum(salary) from ( select salary, ntile(3) over (order by (salary) as threetile from employee) as s group by threetile SQL permits the user to specify where they should occur by using nulls first or nulls last, for instance select student-id, rank ( ) over (order by marks desc nulls last) as s-rank from student-marks

©Silberschatz, Korth and Sudarshan22.7Database System Concepts 4 th Edition 7 Aggregates on Windows An example of window query is that, given sales values for each date, calculates for each date the average of the sales on that day, the previous day, and the next day; such moving average queries are used to smooth out random variations. In contrast to group by, the same tuple can exist in multiple windows. Suppose we are given a relation transaction(account-number, date-time, value), select account-number, date-time, sum(value) over (partition by account-number order by date-time range unbounded preceding) This query returns a new sum for each new tuple—cumulative sum! An actual window can also be specified: e.g. range 10 rows preceding range between 10 rows preceding and 4 following range 30 minutes preceding range interval 30 minutes preceding and current row