mysql - SQL: how to get a weighted count using GROUP BY? -


how can make query like:

select myvalue, count() freq mytable group myvalue; 

but freq sums values weight column instead of counting each row 1?

i'm using mysql 5.1.

select myvalue, sum(weight) freq mytable group myvalue; 

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -