From the course: Querying Microsoft SQL Server 2022
Unlock the full course today
Join today to access over 24,200 courses taught by industry experts.
Challenge: Obtain order summaries - SQL Server Tutorial
From the course: Querying Microsoft SQL Server 2022
Challenge: Obtain order summaries
(upbeat music) - [Instructor] It's time for another challenge. And this time we're going to use aggregate functions to get summary calculations. The Sales.SalesOrderHeader table contains information about every order that's been made. This includes the customer ID that placed the order and the total amount due. Since many customers have placed multiple orders, I want you to summarize this data to find the customers that have spent the most money at AdventureWorks. I'd also like to know their lowest, highest, and average purchase amount. You'll need to use what you've seen with the SUM function and apply it to the MIN, MAX, and AVG functions to find these values. Finally, include the actual first and last name of each customer. You'll need to create a join to the Person.Person table, but the related columns have different names in both tables. So here's a hint. The related field is Sales.OrderHeader.CustomerID is…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Understand record grouping2m 44s
-
(Locked)
Use GROUP BY and COUNT5m 6s
-
(Locked)
Aggregate functions3m 27s
-
(Locked)
Explore data with SUM7m 13s
-
(Locked)
Filter groups with HAVING3m 41s
-
(Locked)
Challenge: Obtain order summaries1m 21s
-
(Locked)
Solution: Obtain order summaries10m 34s
-
(Locked)
Solution: Group rows and aggregate data3m 45s
-
-
-
-
-
-
-