-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Data Analysis Using SQL and Excel - Second Edition
By :
The previous model was a lookup model for classification, both for multiple classification and binary classification. The lookup itself was along a single dimension. This section uses lookup models for estimating a real number. It starts with the very simplest case, no dimensions, and builds the model up from there.
Another basic example of a lookup model is assigning an overall average value. For instance, we might ask the question: Based on purchases in 2015, what do we expect the average order size to be in 2016? The following query answers this question, by using the average of all purchases in 2015:
SELECT YEAR(o.OrderDate) as year, AVG(o.TotalPrice) as avgsize FROM Orders o WHERE YEAR(o.OrderDate) in (2015, 2016) GROUP BY YEAR(o.OrderDate) ORDER BY year
This query gives the estimate of $86.07. This is a reasonable estimate, but it is a bit off the mark because the actual average in 2016 is $113.19. The average could...
Change the font size
Change margin width
Change background colour