当前位置:网站首页>SQL practice: SQL window functions and real problems

SQL practice: SQL window functions and real problems

2022-06-10 06:07:00 Soyoger

During the written test of data analyst interview , Window function is a knowledge point that appears frequently in written examination questions of major companies , Because in practice , Many involve ranking within a group or seeking topN And other related questions , They all have one thing in common , It is not a simple table join or aggregate function that can be implemented , Instead, you need to perform some function operations inside the recordset that meets certain conditions in a single table .

To solve such problems , The most convenient is to use window functions to easily solve , It can be said that window function is a skill that data analysts must master .

What is a window function

The window function is also called OLAP function .OLAP yes Online Analytical Processing For short , It means real-time analysis and processing of database data .

standard SQL The first support for window functions was in SQL-1999 In the extended document of ,MYSQL from 8.0 Window functions are not supported until version , therefore , The following examples are based on MYSQL8.0 Of , Please make sure the correct version is installed .

The basic syntax of window functions

The basic syntax of the window function is as follows :

< Window function > over (partition by < Column name for grouping >
                order 
原网站

版权声明
本文为[Soyoger]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203021305560170.html