Database Reference
In-Depth Information
Figure 13-7.
Results filtered by a given title ID
You may want to filter not only the title but also the date. To do this, you would change the
WHERE
clause to
search for a particular date, as shown in Listing 13-12.
Listing 13-12.
Using a
WHERE
Clause to Filter Based on a Given Date
SELECT
DP.PublisherName
, [Title] = DT.TitleName
, [TitleId] = DT.TitleId
, [OrderDate] = Convert(varchar(50), [Date], 101)
, SalesQuantity
FROM DWPubsSales.dbo.FactSales AS FS
INNER JOIN DWPubsSales.dbo.DimTitles AS DT
ON FS.TitleKey = DT.TitleKey
INNER JOIN DWPubsSales.dbo.DimDates AS DD
ON FS.OrderDateKey = DD.DateKey
INNER JOIN DWPubsSales.dbo.DimPublishers AS DP
ON DT.PublisherKey = DP.PublisherKey
WHERE [Date] = '09/13/1994'
ORDER BY DP.PublisherName, [Title], [OrderDate]
The results will now only show data where the exact date is found (Figure
13-8
).