50% won't know this! #sql #sqlserver #database #dba #data #dataengineer #dataanalytics #datascience

preview_player
Показать описание
These window functions are really great. Do you use window functions?

LEAD() - Accesses data from a subsequent row in the same result set without the use of a self-join starting with SQL Server 2012 (11.x). LEAD provides access to a row at a given physical offset that follows the current row. Use this analytic function in a SELECT statement to compare values in the current row with values in a following row.
Рекомендации по теме
Комментарии
Автор

Hi Sql hero, would this work aswell?

WITH CTE AS (
SELECT
id,
quantity,
lead(quantity) OVER (ORDER BY id) AS next_quantity
FROM transactions
)
SELECT
id,
quantity,
next_quantity
FROM CTE

the_detail_surgeon
Автор

Amazing, thank you! How come your company lets you share this tho?

iBruceKT