select case
    when sum(grade)>500000 then sum(grade)
    else 0
    end
    from test1
    where id>100;
 
update test1
    set grade = case
        when grade < 10000 then grade * 1.05
        else grade * 1.50
    end;
 
条件查询的标准结构如下~
case
    when pred1 then result1
    when pred2 then result2
    ……
    when predN then resultN
    else result0
end