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: Write a query with a subquery - SQL Server Tutorial
From the course: Querying Microsoft SQL Server 2022
Challenge: Write a query with a subquery
(funky upbeat music) - [Instructor] It's time to test your knowledge with another challenge. For the sixth challenge for the course, I'd like you to work with a subquery and the PIVOT command. In the exercise files, find the ChallengeSix-Start.sql file. In it, you'll find a query that counts up the number of products in each category at AdventureWorks. I want you to write a new query that displays the exact same information, only pivoted into a column-oriented structure instead of a row-oriented structure. This means that your column headers will be the names of each category, and the table row will display the count of products. Pivot tables can bring a whole new perspective to your data, and give you additional options for reporting and sharing information with other applications. So take your time and work out the pivot statement to reorient the results. I estimate that this should take about 10 minutes to…
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
-
-
-
-
-
-
-
-
-
(Locked)
What is a subquery?5m 14s
-
(Locked)
Use a subquery in a HAVING clause6m 26s
-
(Locked)
Correlated subqueries6m 29s
-
(Locked)
PIVOT the result set4m 20s
-
(Locked)
Challenge: Write a query with a subquery1m 2s
-
(Locked)
Solution: Write a query with a subquery8m 49s
-
(Locked)
Solution: Obtain information with a subquery5m 44s
-
(Locked)
-
-
-