BaşlayınÜcretsiz Başlayın

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;

Bu egzersiz

Time Series Analysis in SQL Server

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

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.___ = ___;
Kodu Düzenle ve Çalıştır