Time Series Analysis in SQL Server
Maham Faisal Khan
Senior Data Science Content Developer
DATEADD()
and DATEDIFF()
to round dates and times.CAST()
and CONVERT()
when performance matters. FORMAT()
is useful but slow.CAST()
, CONVERT()
, and PARSE()
can all turn strings into dates.TRY_CAST()
, TRY_CONVERT()
, and TRY_PARSE()
for safe date conversions.SWITCHOFFSET()
and TODATETIMEOFFSET()
are useful functions for working with offsets.COUNT()
, MIN()
, MAX()
, and SUM()
.AVG()
, STDEV()
, VAR()
, STDEVP()
, and VARP()
.ROLLUP
, CUBE
, and GROUPING SETS
allow you to refine your aggregations.ROW_NUMBER()
, RANK()
, DENSE_RANK()
, and NTILE()
) as well as aggregate functions (including statistical functions).SUM()
over a window.AVG()
over a window.LAG()
and LEAD()
let us peek backward and forward in time.Time Series Analysis in SQL Server