CASE
WHEN (select capgrade
from tb_tpost_userpost
where mpostid = i.mpostid
and spostid = i.spostid
and idcard = r.idcard) = 1 THEN
'Ⅰ级'
WHEN (select capgrade
from tb_tpost_userpost
where mpostid = i.mpostid
and spostid = i.spostid
and idcard = r.idcard) = 2 THEN
'Ⅱ级'
WHEN (select capgrade
from tb_tpost_userpost
where mpostid = i.mpostid
and spostid = i.spostid
and idcard = r.idcard) = 3 THEN
'Ⅲ级'
WHEN (select capgrade
from tb_tpost_userpost
where mpostid = i.mpostid
and spostid = i.spostid
and idcard = r.idcard) = 4 THEN
'Ⅳ级'
WHEN (select capgrade
from tb_tpost_userpost
where mpostid = i.mpostid
and spostid = i.spostid
and idcard = r.idcard) = 5 THEN
'Ⅴ级'
ELSE
'尚无等级'
END usercapgrade
语句太过长了,这个怎么改成外层嵌套一次查询,大佬帮忙看一下,谢谢