Get the App
SLTechnology News&Howtos  ›  Database  › 

How does mysql count the number of people in each major score segment?

Shulou Source: shulou.com Published: 2022-06-01 21:48:45 09月29日 Update

How does mysql count the number of people in each major score segment? The following will be introduced in detail by the editor.

1. My watch structure

Student_info | id | name | profession | score | |-| id | name | score | Specialty |

two。 Statistics by fractional segment

400 to 500 people, 300 to 400 people

Selectcount (case when score between 400 and 500 then 1 end) as 400 to 500 and count (case when score between 300 and 400 then 1 end) as 300 to 400from student_info

3. Statistics by score segment and specialty

400 to 500 people, 300 to 400 people

Selectcount (case when score between 400 and 500 then 1 end) as 400 to 500 and count (case when score between 300 and 400 then 1 end) as 300 to 400from student_info GROUP BY profession

4.sql dynamic splicing generation

Int start = 200; int end = 700; int inter = 10; int count = (end-start) / inter; StringBuilder sqlBuilder = new StringBuilder (); sqlBuilder.append ("select"); for (int I = 1teri

Tags: Number of people scores majors score segments statistics dynamics names that is articles more structure generation output Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia OPPO Reno Apple Redmi Huawei