Skip to main content

Window Operator in RDBMS

  • Reference work entry
  • First Online:
  • 27 Accesses

Synonyms

Analytic OLAP functions; Window functions; Window operator

Definition

Window functions, also known as analytic OLAP functions, were introduced in SQL to simplify the formulation of many useful queries that require computations such as ranking, cumulative sums, and moving averages. Window functions are most commonly used in the select clause of SQL queries to compute additional column values for each output tuple, and they could also be used in the order-by clause to compute column values for ordering.

As an example, consider a relation Sales (branch, day, amount) which records the daily sales figures for each branch of a company. To compute the seven-day moving average sales for each branch, one could express the query using a self-join as follows:

SELECT

s1.branch, s1.day, s1.amount,

 

(SELECT AVG(x.amount) FROM

 

(SELECT s2.amount AS amount

 

FROM Sales s2

 

WHERE s2.branch = s1.branch

 

AND s2.day <= s1.day

 

ORDER BY s2.day DESC LIMIT

 

7) AS x) AS movingAvg

FROM

Sales s1

The above...

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   4,499.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Hardcover Book
USD   6,499.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Recommended Reading

  1. Bellamkonda S, Ahmed R, Witkowski A, Amor A, Zait M, Lin C-C. Enhanced subquery optimizations in Oracle. Proc VLDB Endow. 2009;2(2):1366–77.

    Article  Google Scholar 

  2. Bellamkonda S, Bozkaya T, Ghosh B, Gupta A, Haydu J, Subramanian S, Witkowski A. Analytic functions in Oracle 8i. Technical report, Oracle Corporation. 2000.

    Google Scholar 

  3. Bellamkonda S, Li H-G, Jagtap U, Zhu Y, Liang V, Cruanes T. Adaptive and big data scale parallel execution in Oracle. Proc VLDB Endow. 2013;6(11): 1102–13.

    Article  Google Scholar 

  4. Cao Y, Chan C-Y, Li J, Tan K-L. Optimization of analytic window functions. Proc VLDB Endow. 2012;5(11):1244–55.

    Article  Google Scholar 

  5. Eisenberg A, Melton J, Kulkarni K, Michels J-E, Zemke F. SQL:2003 has been published. SIGMOD Rec. 2004;33(1):119–26.

    Article  Google Scholar 

  6. Leis V, Kundhikanjana K, Kemper A, Neumann T. Efficient processing of window functions in analytical SQL queries. Proc VLDB Endow. 2015;8(10): 1058–69.

    Article  Google Scholar 

  7. Ma J, Cao Y, Wang X, Wang C, Jin C, Zhou A. PGWinFunc: optimizing window aggregate functions in PostgreSQL and its application for trajectory data. In: Proceedings of the 31st International Conference on Data Engineering; 2015. p. 1448–51.

    Google Scholar 

  8. PostgreSQL Global Development Group. Window Functions, Chapter 3.5. PostgreSQL Documentation. http://www.postgresql.org/docs/9.5/static/tutorial-window.html.

  9. Ramakrishnan R, Donjerkovic D, Ranganathan A, Beyer K, Krishnaprasad M. SRQL: sorted relational query language. In: Proceedings of the 10th International Conference on Scientific and Statistical Database Management; 1998. p. 84–95.

    Google Scholar 

  10. Zemke F. What’s new in SQL:2011. SIGMOD Rec. 2012;41(1):67–73.

    Article  Google Scholar 

  11. Zuzarte C, Pirahesh H, Ma W, Cheng Q, Liu L, Wong K. WinMagic: subquery elimination using window aggregation. In: Proceedings of the ACM SIGMOD International Conference on Management of Data; 2003. p. 652–56

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Chee-Yong Chan .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Springer Science+Business Media, LLC, part of Springer Nature

About this entry

Check for updates. Verify currency and authenticity via CrossMark

Cite this entry

Chan, CY. (2018). Window Operator in RDBMS. In: Liu, L., Özsu, M.T. (eds) Encyclopedia of Database Systems. Springer, New York, NY. https://doi.org/10.1007/978-1-4614-8265-9_80628

Download citation

Publish with us

Policies and ethics