我有一个表格保存这样的记录
a, 5
a, 6
a, 7
a, 8
b, 1
b, 2
b, 3
c, 1
c, 2
c, 3
c, 4
c, 5
我想要每个键的平均值 - >
a, (5+6+7+8)/4 = 6.5
b, ..
c, ..
任何提示?
答案 0 :(得分:0)
let column item and value, so your table like this item,value a, 5 a, 6 a, 7 a, 8 b, 1 b, 2 b, 3 c, 1 c, 2 c, 3 c, 4 c, 5 SELECT item,AVG(VALUE) as avg FROM Test.Testing GROUP BY item; item ,avg a, 7.2500 b, 2.0000 c, 2.5000