Q. What is Window Function?
A. The window function is a type of function that allows us to perform calculations across specific set of rows.
Q. What is different with aggregate functions?
A. Aggregate functions summarize data for the entire group(entire data set or group defined by the GROUP BY clause). However, the window functions allow detailed calculations for specific partitions or subsets of data.
Q. Syntax?
select column_name1,
window_function(column_name2) over (partition by column_name1 order by column_name3) as new_column
from table_name
- row_number(), lead(), lag() are the window functions
- the window function is applied within the partition
- within the partition, the dataset is ordered based on the ORDER BY clause
Q. I want to see conditioned data
A. The WHERE clause is now allowed. But, you can give the condition, using CTE.
First, write the query using the window function. Then define the query as a subquery, using CTE.
(Reference)
Window Functions in SQL - GeeksforGeeks
SQL window functions enable advanced data analysis by performing calculations across specific rows while retaining individual data, utilizing the OVER clause for partitioning and ordering.
www.geeksforgeeks.org
'#독학로그_IT,개발,데이터' 카테고리의 다른 글
window에서 chocolatey로 mongoDB 설치하기 (0) | 2022.04.17 |
---|