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

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…

Contents