Would you help me, please, to make pivot table from this (database in MS SQL Server 2016):
clients date_start date_end result
----------------------------------------
client1 01.09.2019 05.09.2019 red
client1 01.09.2019 05.09.2019 blue
client1 01.09.2019 05.09.2019 green
client2 01.09.2019 05.09.2019 red
client2 01.09.2019 05.09.2019 blue
client3 01.09.2019 05.09.2019 yellow
into this:
clients red blue green yellow
----------------------------------
client1 1 1 1
client2 1 1
client2 1
Details: I have a table with clients' results. Each result is unique and it contains datestart and date_end. I wanna select clients' results on specific date. If date is between date_start and date_end, it goes into the pivot table.
Initially, we don't know all the kinds of results (i.e. it can be orange tomorrow). It should be dynamic.