Please tell me how to write a sql statement.

now I have written two sql statements and the results are both posted:
select DATE_FORMAT (date,"%Y-%m") as month , round (avg (aql), 2) as avgAQL from cj_tianqi_list group by month order by month
clipboard.png

`select
COUNT(if(avgAQL>50&&avgAQL<101,true,null)) as "",
COUNT(if(avgAQL>100&&avgAQL<151,true,null)) as "",
COUNT(if(avgAQL>150&&avgAQL<201,true,null)) as "" from(
select DATE_FORMAT(date,"%Y-%m") as month,round(avg(aql),2) as avgAQL from cj_tianqi_list group by month order by month
) as b`

clipboard.png
but the result I want is
state num
good 30
mild pollution 23
moderate pollution 5

ask for God!

Mar.11,2021

select state, count(*)
from (
    select 
        case 
          when avgAQL>50  &&  avgAQL<101 then ''
          when avgAQL>100 &&  avgAQL<151 then ''
          when avgAQL>150 &&  avgAQL<201 then ''
          else ''
        end as state
    from t
)
group by state
order by state

Sorry, every time I know what the specific problem is

Menu