In SQL, how can you “group by” in ranges?

前端 未结 15 2401
粉色の甜心
粉色の甜心 2020-11-22 15:38

Suppose I have a table with a numeric column (lets call it \"score\").

I\'d like to generate a table of counts, that shows how many times scores appeared in each ran

15条回答
  •  旧时难觅i
    2020-11-22 16:29

    select cast(score/10 as varchar) + '-' + cast(score/10+9 as varchar), 
           count(*)
    from scores
    group by score/10
    

提交回复
热议问题