From the course: From Excel to SQL

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using a pivot table in SQL

Using a pivot table in SQL

From the course: From Excel to SQL

Start my 1-month free trial

Using a pivot table in SQL

- So let's imagine you want to find out how many t-shirts of each size you need to purchase for all the employees in your company. In Excel, you could use a simple pivot table to put this kind of data together. And perhaps you already have some experience with pivot tables doing something similar. So what would this look like in SQL. In the sample spreadsheet, I provided an example of a pivot table, under the pivot table, employee sheet. And you can see, in this pivot table, we have the t-shirt sizes listed. And then, how many of the t-shirt sizes we'd need to purchase. So let's open up DB browser and have a look at how we might create a pivot table. Right off the bar, you need to know that there is no pivot table command or function in SQL, but don't worry. You can achieve similar results in SQL by making use of the GROUP BY clause. So within DB browser, let's create a query to return the number of t-shirts in…

Contents