Getting data for histogram plot

前端 未结 10 730
花落未央
花落未央 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:03

    SELECT
        CASE
            WHEN total <= 30 THEN "0-30"
            WHEN total <= 40 THEN "31-40"       
            WHEN total <= 50 THEN "41-50"
            ELSE "50-"
        END as Total,
        count(*) as count
    GROUP BY Total 
    ORDER BY Total;
    

提交回复
热议问题