Database Reference
In-Depth Information
Figure 13-10 shows the results of the query.
Figure 13-10. Results filtered with the IN operator
The second operator that is worthy of mentioning is the BETWEEN operator. It finds data that is within a range,
such as numeric or alphabetical. Listing 13-15 demonstrates this operator using dates.
Listing 13-15. Using the BETWEEN Operator
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] BETWEEN '09/13/1994' AND '09/14/1994'
ORDER BY DP.PublisherName, [Title], [OrderDate]
As you can see in Figure 13-11 , all rows of data are returned that are within the range of dates specified by
the BETWEEN operator.
 
Search WWH ::




Custom Search