ComeçarComece de graça

Joining to a calendar table

In the prior exercise, we looked at a new table, dbo.Calendar. This table contains pre-calculated date information stretching from January 1st, 2000 through December 31st, 2049. Now we want to use this calendar table to filter another table, dbo.IncidentRollup.

The Incident Rollup table contains artificially-generated data relating to security incidents at a fictitious company.

You may recall from prerequisite courses how to join tables. Here's an example of joining to a calendar table:

SELECT
    t.Column1,
    t.Column2
FROM dbo.Table t
    INNER JOIN dbo.Calendar c
        ON t.Date = c.Date;

Este exercício faz parte do curso

Time Series Analysis in SQL Server

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

SELECT
	ir.IncidentDate,
	c.FiscalDayOfYear,
	c.FiscalWeekOfYear
FROM dbo.___ ir
	INNER JOIN dbo.___ c
		ON ir.___ = c.___
WHERE
    -- Incident type 3
	ir.___ = 3
    -- Fiscal year 2019
	AND c.___ = ___
    -- Fiscal quarter 3
	AND c.___ = ___;
Editar e executar o código