I got a transactional table which has data for each and every minute. Have to Grouping this table and do a Pivot based on a Row value. Let me list the Example and Output below. Key value is "CH5".
Output: (Pivot table based on CH5 - Previous to CH5 must be in the rows with Order. Here Source Channel will be always CH5. And an additional Next channel to be displayed. (its restricted to one Channel). Previous it must be till CH5 Occurs.
[Time] [SourceChannel] [PreCH1] [PreCH2] [PreCH3] [PreCH4] [NEXTCH]
19.32 CH5 CH2 CH1 NULL NULL CH4
19.34 CH5 CH1 CH4 NULL NULL
19.35 CH5 NULL NULL NULL NULL
19.36 CH5 NULL NULL NULL NULL CH3
19.43 CH5 CH2 CH3 NULL NULL CH6
Above output has based on CH5. Following First Channel will be pivoted for the NextCH, Previous Time channels will be pivoted into PreCH columns till CH5 occurs..