From the course: Complete Your First Project in SQL
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Solution: Average daily sales - SQL Tutorial
From the course: Complete Your First Project in SQL
Solution: Average daily sales
(upbeat music) - [Instructor] Welcome back. Excellent work on finding out the average daily sales. If this challenge felt overwhelming, don't worry. I will walk you through the code step-by-step to explain how to accomplish this task. So if we head over to Codespaces, you can begin your code by using a SELECT statement and then jump right in to creating your average daily sales column. For this one, you'll want to use the SUM function on the quantity column to gather the total number of items sold. Then you will be dividing this by the days. For this column, you'll want to use the COUNT function on the creation date column, but make sure you add in DISTINCT to ensure you only count each date once. This will gather the distinct number of days where at least one item was sold. You can alias this new column as AverageDailySales. You'll gather this data from the Orders table and then do a LEFT OUTER JOIN on the OrderItem table. For these two tables, you will join them on their OrderID…
Contents
-
-
-
-
(Locked)
How to find how many products sold2m 23s
-
(Locked)
How to find which items are discontinued1m 16s
-
(Locked)
How to find any sales people who made no sales5m 45s
-
(Locked)
How to find the top product size sold2m 48s
-
(Locked)
How to find the top three items sold2m 49s
-
(Locked)
How to find sales by month and year3m 38s
-
(Locked)
Challenge: Average daily sales1m 40s
-
(Locked)
Solution: Average daily sales1m 56s
-
(Locked)
-
-