我怎麼能做出這樣的查詢:SQL:如何使用GROUP BY得到加權計數?
select myvalue, count() as freq from mytable group by myvalue;
但是,在freq
總和值從weight
柱代替數數每排爲1?
我正在使用MySQL 5.1。
我怎麼能做出這樣的查詢:SQL:如何使用GROUP BY得到加權計數?
select myvalue, count() as freq from mytable group by myvalue;
但是,在freq
總和值從weight
柱代替數數每排爲1?
我正在使用MySQL 5.1。
select myvalue, sum(weight) as freq from mytable group by myvalue;
select myvalue, SUM(weight) as freq from mytable group by myvalue;
使用sum(weight) as freq
在您選擇查詢