Skip to Content
SQL Query Design Patterns and Best Practices
book

SQL Query Design Patterns and Best Practices

by Steven Hughes, Dennis Neer, Ram Babu Singh, Shabbir Mala, Leslie Andrews, Chi Zhang
March 2023
Intermediate to advanced
270 pages
5h 51m
English
Packt Publishing
Content preview from SQL Query Design Patterns and Best Practices

7

Reshaping Data with Advanced Techniques

When working with data, we sometimes find that we need to reshape it in order for it to be useful for storing in a table or to use that data for reporting purposes, and to do that, we transpose data by either moving columns to rows (or vice versa) and/or storing data in a hierarchical structure.

In this chapter, you will learn three advanced ways of reshaping data—PIVOT, UNPIVOT, and hierarchies, to manipulate data into meaningful output.

We will cover each topic in three main sections:

  • Working with the PIVOT operator
  • Working with the UNPIVOT operator
  • Understanding hierarchical data

Technical requirements

To work with the examples and illustrations in this chapter, you will need to have Azure Data ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

You might also like

Effective SQL: 61 Specific Ways to Write Better SQL, First Edition

Effective SQL: 61 Specific Ways to Write Better SQL, First Edition

John L. Viescas, Douglas J. Steele, Ben G. Clothier
Patterns for API Design: Simplifying Integration with Loosely Coupled Message Exchanges

Patterns for API Design: Simplifying Integration with Loosely Coupled Message Exchanges

Olaf Zimmermann, Mirko Stocker, Daniel Lubke, Uwe Zdun, Cesare Pautasso

Publisher Resources

ISBN: 9781837633289