Mark As Completed Discussion

Value Window Functions

With the use of these functions, you can easily extract values from other rows that could be beneficial in a report. NTILE(), LEAD(), and LAG() are the three value functions that are most often utilized.

  • LAG() and LEAD() - To generate a column that can draw data from other rows, we may utilize the LAG or LEAD functions. LEAD returns values from the rows after it, whereas LAG might return values from the rows before it. These two functions might come in handy when analyzing variations over time and dealing with time series data and comparing prior or subsequent rows.
  • NTILE() – The NTILE() function is used for determining which percentile, quartile, or other division a given row belongs in. In this case, the ORDER BY clause chooses the columns that should be used for determining the quartiles.