select id,(case when ifnull(@val,-1.1) <> ifnull(AAA_yfjfbz,-1.1) then @newrow:
[email protected]+1 else @newrow end) as newid,(p_pcount - @newrow + 1) as star,(@val:=AAA_yfjfbz) as dbval from AAA_element where area_clstype = p_clstype order by AAA_yfjfbz desc;