I want to design a query to compute some returns for stock data and in searching the 'SQL Server Books Online' I find a very small and not so helpful at all help section on the lead and lag functions.
-- By using MAX as an window function, SQL will not reduce records but the result will be shown corresponding to each record. rank() over(partition by dept_name order ...
LAG(month_0) OVER(Partition by brand, pc) as prev_month, /* nowa kolumna z wartoscia z ostatniego aktywnego miesiaca */ month_0 - LAG(month_0) OVER(Partition by brand, pc) as day_change /* roznica dni ...
Some results have been hidden because they may be inaccessible to you
Show inaccessible results