SQL implementation is similar to EXCEL row and column transposition