access中纵行转横行
id newcode code area
1 111 11 20
1 112 12 30
1 113 13 50
2 211 11 10
2 221 21 90
3 311 11 10
3 313 13 90
如何把上述表转换成:
id code11 code12 code13 code21
1 20 30 50 0
2 10 0 0 90
3 10 0 0 90
并计算从code11--code21中的最大值和最小值
------解决方案--------------------TRANSFORM nz(max([area]),0)
SELECT [id], min(nz(area,0)) AS mi,max(nz(area,0)) as ma
FROM ttqa
GROUP BY [id]
PIVOT 'code ' & [code];