MySQL query example using LAG and LEAD window functions to display previous and next scores relative to each row in the scores table.

This image displays a MySQL query that utilizes the LAG() and LEAD() analytical functions to calculate values from adjacent rows in the scores table. The query orders the data by the score column and uses window functions to fetch the previous and next score for each row. The results are shown in a table format with columns for name, score, BeforeValue (LAG), and AfterValue (LEAD). This example highlights the practical use of window functions for comparative data analysis in SQL.

×

Table Of Content