Interview

Window functions in SQL Server

In SQL Server we have different categories of window functions

  • Aggregate functions – AVG, SUM, COUNT, MIN, MAX etc..
  • Ranking functions – RANK, DENSE_RANK, ROW_NUMBER etc..
  • Analytic functions – LEAD, LAG, FIRST_VALUE, LAST_VALUE etc…

OVER Clause defines the partitioning and ordering of a rows (i.e a window) for the above functions to operate on. Hence these functions are called window functions. The OVER clause accepts the following three arguments to define a window for these functions to operate on.

  • ORDER BY : Defines the logical order of the rows
  • PARTITION BY : Divides the query result set into partitions. The window function is applied to each partition separately.
  • ROWSor RANGE clause : Further limits the rows within the partition by specifying start and end points within the partition.

About the author

Avatar of shohal

shohal

I have profession and personal attachment with custom ERP Software development, Business Analysis, Project Management and Implementation almost (36) ,also Oracle Apex is my all-time favorite platform to developed the software. Moreover i have some website development experience with WordPress. For hand on networking experience DevOps and CCNA, it create me a full package. Here are some core programming language with networking course i have been worked: Oracle SQL ,PL/SQL,Oracle 19c Database , Oracle Apex 20.1,WordPress,Asp.Net ,MS SQL ,CCNA ,Dev Ops, SAP SD

Leave a Comment