mysql - Find all occurances of a same values -


hello , thank in advance,

so have table lets call userrating , inside table have fields, 1 of called userid.

below demonstrate how table looks like.

userid  |  rating1  |  rating2 |  rating3  |  rating4 | rating5 ----------------------------------------------------------- 100     |    1      |    0     |    0      |    0     |    0 101     |    0      |    0     |    1      |    0     |    0 101     |    0      |    0     |    0      |    0     |    1 112     |    0      |    1     |    0      |    0     |    0 100     |    0      |    0     |    0      |    1     |    0 101     |    1      |    0     |    0      |    0     |    0 

what want rows same userid's.

i want 2 occurances 100, 3 occurances 101 , 1 occurance 112.

try

select userid, sum(rating1),sum(rating2),sum(rating3),sum(rating4),sum(rating5)  userrating group userid  

also check here on fiddle - http://sqlfiddle.com/#!9/598b9/3


Comments