Browsed by
Tag: PIVOT

PIVOTS with Unknown Values – Dynamic SQL

PIVOTS with Unknown Values – Dynamic SQL

As promised, although it took 3 years, I’ll show you how to use PIVOTS with unknown values. This is a continuation of the other PIVOT post. If you haven’t already, it’s not a bad idea to read it first. (Create Employee Work Shift Schedule using PIVOTS) We’ll use the same code to start off. The prep code is the same. Last time we predefined the time values like the code below But instead of listing the times, let’s concatenate the…

Read More Read More

Create Employee Work Shift Schedule using PIVOTS

Create Employee Work Shift Schedule using PIVOTS

Once in awhile, it is required of you to create visualizations of the data you have in the database.For example, you have a set of data of employees and when they start their shift and when it ends.But you would like to create a chart for the day to see which employees work together. Fortunately, creating this chart is easy in SQL Server using Common Table Expressions (CTE) and Pivot.The sample data we will use is the data seen below….

Read More Read More