Database Reference
In-Depth Information
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
, CONVERT(varchar(50), [Date], 101)
--ORDER BY DP.PublisherName, [Title], [OrderDate]
Not With all these restrictions, you might wonder why one would ever use a VIEW statement, but keep in
mind that many reporting applications can provide features you cannot include in the view itself once the view has
returned all of the unfiltered results to the application.
Once a view has been created, you can use the view by selecting it as if it were a table. The code to do so will
look similar to Listing 13-23.
Listing 13-23. Using Your View Without Filters
SELECT
PublisherName
, [Title]
, [TitleId]
, [OrderDate]
, [Total for that Date by Title]
FROM vQuantitiesByTitleAndDate
When the SELECT Statement is run, you receive all the results from the view including the aggregated daily
totals. Figure 13-19 shows these results.
 
Search WWH ::




Custom Search