Solved

SQL Server Examples of Pivot Tables

Posted on 2014-01-23
2
2,520 Views
Last Modified: 2014-01-26
Hi
Does anyone know of a site that shows a few examples of SQL Pivot table queries.
I tried W3Schools but couldn't find anything there
0
Comment
Question by:murbro
2 Comments
 
LVL 16

Accepted Solution

by:
Surendra Nath earned 250 total points
ID: 39803943
0
 
LVL 59

Assisted Solution

by:Kevin Cross
Kevin Cross earned 250 total points
ID: 39804096
You can try Mark and my articles here at EE:

-Dynamic Pivot Procedure for SQL Server
-Pivot Rolling Periods Without Using Dynamic T-SQL
-Broaden Your Horizons : Pivot Again!

The Technet article above is pretty good, though.  You should be able to construct most queries you need from there.  The key to remember is you need a finite, pre-defined list for PIVOT.  If not, you will have to use dynamic SQL.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now