Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The detailed explanation of windowing function in SQL can be used instead of aggregate function.

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Before learning the windowing function, we all know that after using grouping, the query fields can only be grouped fields and aggregated fields, which brings great inconvenience. Sometimes we need to query the fields that are not grouped, and every time we have to go to the subquery, so it appears that the sql statement is complex and difficult to understand, which brings great pain to the people who maintain the code. However, the windowing function has appeared and the dawn has come. If you want to learn more about windowing functions, please read the SQL Code of programmers. Windowing functions are not available in mysql.

Windowing functions, like aggregate functions, aggregate the set of rows. It is used to define a window for rows (in this case, the window is a collection of rows to be operated on), it operates on a set of values, does not need to use group by statements to group the data, and can return the columns of the underlying row and aggregate columns in the same row at the same time. It doesn't matter if you don't understand the definition, as long as you can use it.

To take a simple example, query the information of each employee whose salary is less than 5000 (name, city age salary), and display the number of employees less than 5000, try using the following statement:

SELECT FName, FCITY, FAGE, FSalary, COUNT (FName) FROM T_Person WHERE FSALARY

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report