-- File Name: Michal_Stanek_tsqlchallenge_15.sql select Row, [1], [2], [3], [4], [5], [6], [7], [8], [9] from ( select R.Row, C.Col, case when R.Row % C.Col = 0 then 'x' else '' end as Mark from @Cols C full join @Rows R on 1=1 ) res pivot ( max(Mark) for Col in ([1], [2], [3], [4], [5], [6], [7], [8], [9]) ) PivotTable
Did you find something incorrect/wrong with this solution? Take a few seconds to Report It.
Did you understand how this solution work? If you find it difficult to understand, you can Request an Explanation or you can Write an explanation to help others better understand this solution.