如何进行如下查询:
select myvalue, count() as freq from mytable group by myvalue;
但是freq
对weight
列的值求和而不是将每行计为1?
我正在使用MySQL 5.1。
答案 0 :(得分:3)
答案 1 :(得分:2)
select myvalue, sum(weight) as freq from mytable group by myvalue;
答案 2 :(得分:2)
select myvalue, SUM(weight) as freq from mytable group by myvalue;
答案 3 :(得分:1)
在您的选择查询中使用sum(weight) as freq