我有一组数据:
id maths phy chem
1 50 60 21
2 60 80 22
3 80 90 23
现在我希望它看起来像这样:
sub 1 2 3
math 50 60 80
phy 60 80 90
chem 21 22 23
我的代码:
select *
from mrks
pivot
(
max(maths)
for id in ([1], [2], [3])
) piv
然而,我面临着两个问题:
我无法转置化学和物理值
无法将数学、物理和化学分组到科目下