交叉查询问题 - (sum& avg)

时间:2009-06-10 05:27:07

标签: database ms-access-2007

是否可以使用交叉查询来执行此操作? (在Access 2007中)

我有这张桌子:

50 | A1

60 | A1

70 | B1

80 | B1

90 | C1

我需要得到这个结果:

A1 ------------------ B1 --------------- C1

总和|平均-----总和|平均-----总和|平均

55 | 110 --------- 75 | 130 ------ 90 | 90

我试着怀疑这个:

TRANSFORM Sum(Worki.Value) AS XXsum
SELECT Worki.Name AS Name, Worki.Tdate AS Tdate, Worki.ID AS ID
FROM Worki
GROUP BY Worki.Name, Worki.Tdate, Worki.ID
PIVOT Worki.Trit;

我如何获得平均值和总和?

1 个答案:

答案 0 :(得分:1)

尝试

select sum(colname),avvg(colname) from tablename group by colname