Hello All,
I need help writing SQL query to display data in different format Dynamically. Here is the current format of the data
WC Name | Version | Weekday | Start Time | End Time | Break | Capacity utilization |
---|---|---|---|---|---|---|
ABC | 1 | Mon | 8:00:00 | 17:00:00 | 1:00:00 | 40 |
ABC | 1 | Tue | 7:00:00 | 16:00:00 | 2:00:00 | 20 |
ABC | 2 | Mon | 6:00:00 | 16:00:00 | 1:00:00 | 70 |
ABC | 2 | Tue | 5:00:00 | 19:00:00 | 3:00:00 | 10 |
DEF | 1 | Mon | 3:00:00 | 17:00:00 | 1:00:00 | 60 |
DEF | 1 | Tue | 7:00:00 | 16:00:00 | 2:00:00 | 20 |
DEF | 2 | Mon | 6:00:00 | 16:00:00 | 1:00:00 | 30 |
DEF | 2 | Tue | 5:00:00 | 19:00:00 | 2:00:00 | 10 |
I need data to be displayed to below format.
WC Name | Version | Weekday | Mon | Tue |
---|---|---|---|---|
ABC | 1 | Start Time | 08:00:00 | 7:00:00 |
ABC | 1 | End Time | 17:00:00 | 16:00:00 |
ABC | 1 | Break | 1:00:00 | 2:00:00 |
ABC | 1 | utilization | 40 | 20 |
ABC | 2 | Start Time | 6:00:00 | 5:00:00 |
ABC | 2 | End Time | 16:00:00 | 19:00:00 |
ABC | 2 | Break | 1:00:00 | 3:00:00 |
ABC | 2 | utilization | 70 | 10 |
DEF | 1 | Start Time | 3:00:00 | 7:00:00 |
DEF | 1 | End Time | 17:00:00 | 16:00:00 |
DEF | 1 | Length of breaks | 1:00:00 | 2:00:00 |
DEF | 1 | utilization | 60 | 20 |
DEF | 2 | Start Time | 6:00:00 | 5:00:00 |
DEF | 2 | End Time | 16:00:00 | 19:00:00 |
DEF | 2 | Break | 1:00:00 | 2:00:00 |
DEF | 2 | utilization | 30 | 10 |
Can you please help? I have tried union and temp table logic and did not work. Thank you so much in advance.