Database Reference
In-Depth Information
SELECT
DP.PublisherName
, [Title] = DT.TitleName
, [TitleId] = DT.TitleId
, [OrderDate] = CONVERT(varchar(50), [Date], 101)
, [Total for that Date by Title] = SUM(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
@ShowAll = 'True'
OR
[Date] BETWEEN @StartDate AND @EndDate
AND
[TitleId] LIKE @Prefix
GROUP BY
DP.PublisherName
, DT.TitleName
, DT.TitleId
, [Date]
ORDER BY DP.PublisherName, [Title], [OrderDate]
Figure 13-15 shows the results of the aggregations.
Figure 13-15. Results with aggregations
Search WWH ::




Custom Search