Mysql, AVG and Count question -


id,    rating_id , rating_num  33100,   '4028',      2,  33099,   '4041',      2,  33098,   '1889',      4,  33097,   '1889',      5,  33096,   '4050',      2, 33095,   '8578',      2,  33094,   '8578',      4, 33093,   '8578',      5, 33093,   '8578',      5, 

guys 3 questions

1) how can see rating_id has received more 3 counts of rating_num ? (answer: 8578)

2) how can see average rating_num of each rating_id ?

3) how can see average rating_num of each rating_id received more 3 counts of rating_num ? ( answer: 4 )

thanks replying classs attender of mysql4dumbmies

1

select rating_id     yourtable     group rating_id     having count(*) > 3 

2

select rating_id, avg(rating_num) average_rating     yourtable     group rating_id 

3

select rating_id, avg(rating_num) average_rating     yourtable     group rating_id     having count(*) > 3 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -