Skip to content
Advertisement

Pivoting Days/Hours in SQL Server From Header to Row Level

I have a list of hours that are under headings from and to. I need to Pivot those to be by days with from and to headings. I’ve tried unpivoting in Excel and Pivot in SQL Server, nothing is working. Each day is corresponded to a SEQ_NO (Monday = 10, Tuesday = 20, etc.). The main problem here is getting the start and end times to be in a different view. Below is the before and after which I want it to look like. Below is Before and After (what I want it to look like).

What I want it to look like
After View (what I want it to look like):

Before:

After:

Advertisement

Answer

I believe you could use UNPIVOT:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement