People, I turn to you because google has not been very helpful for what I need.
I am looking for a way to make a dynamic pivot with 2 columns. Example:
I have this:
id rut fecha entrada salida
2 15114999 2017-10-16 00:00:00.000 9:00 :
626 15114999 2017-10-16 00:00:00.000 11:00 13:00
627 15114999 2017-10-16 00:00:00.000 13:30 14:00
628 15114999 2017-10-16 00:00:00.000 15:00 16:00
629 15114999 2017-10-16 00:00:00.000 16:20 16:30
630 15114999 2017-10-16 00:00:00.000 17:00 17:30
631 15114999 2017-10-16 00:00:00.000 18:00 19:00
3 15114999 2017-10-17 00:00:00.000 9:00 22:00
4 15114999 2017-10-18 00:00:00.000 9:00 14:00
and I require this result
rut fecha entrada salida entrada2 salida2 entrada3 salida3 entrada4 salida4 entrada5 salida5 entrada6 salida6 entrada7 salida7
15114999 2017-10-16 00:00:00.000 9:00 : 11:00 13:00 13:30 14:00 15:00 16:00 16:20 16:30 17:00 17:30 18:00 19:00
15114999 2017-10-17 00:00:00.000 9:00 22:00
15114999 2017-10-18 00:00:00.000 9:00 14:00
The id is not correlative.
I quickly did this little example, what I did was I gave the outputs and inputs an order number, then I pivoted them separately based on that number. In the end I joined the two tables with a join and grouped them by date.
I know it's not very nice to say but I hope it can be of some use to you. Greetings.