Skip to content

SelectDistinct.io

A tech blog about data, warehousing and analytics.

Tag: sqlfoo

SQL Foo | Multi-Column Pivot & Unpivot

November 14, 2016 / Matt / Leave a comment

Multi-Column Pivot & Unpivot with SQL

Multi-Column Pivot & Unpivot with SQL

Just for fun: Let’s look at some interesting ways to solve a multi-column pivot or unpivot (aka crosstab). Some methods are not ANSI standard and others simply won’t work on certain RDBMSs, but we’ll play around with some methods that I came up with using SQL Server 2016.

Let’s start by creating us some data!

Continue reading →

Recent Posts

  • Plural Table Name(s)
  • SQL | Find Patterns In A Dataset
  • When To Use A CTE – And When Not To
  • ETL, DDL, & Self-Documenting Code Generator
  • It’s Performance Review Time!

Categories

  • Business Objects Data Services
  • DBMS
  • Dimensional Design
  • Interview Questions
  • Javascript
  • JSON
  • Python
  • Random Thoughts
  • Reporting
  • SAP
  • SQL Foo
  • SSRS
  • Window Functions

Archives

  • October 2020
  • July 2019
  • June 2019
  • May 2019
  • November 2018
  • September 2018
  • July 2018
  • June 2018
  • May 2018
  • March 2018
  • February 2018
  • December 2017
  • October 2017
  • September 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
Delivery by Matt Komyanek