Getting data for histogram plot

前端 未结 10 713
花落未央
花落未央 2020-11-29 15:27

Is there a way to specify bin sizes in MySQL? Right now, I am trying the following SQL query:

select total, count(total) from faults GROUP BY total;
<         


        
10条回答
  •  北海茫月
    2020-11-29 16:16

    That should work. Not so elegant but still:

    select count(mycol - (mycol mod 10)) as freq, mycol - (mycol mod 10) as label
    from mytable
    group by mycol - (mycol mod 10)
    order by mycol - (mycol mod 10) ASC
    

    via Mike DelGaudio

提交回复
热议问题