-- File Name: syed_mehroz_alam_tsqlchallenge_15.sql
Select *
from
(
Select *, case when Row%Col=0 then 'x' else '' end as Divisible
from @Cols
cross join @Rows
) as t
pivot (Min(Divisible) for Col IN ([1],[2],[3],[4],[5],[6],[7],[8],[9])) as Pvt
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.