日期:2014-05-17 浏览次数:20977 次
with t as(
select 'type_a' 类型,
case when 参数a < 5 then '好'
when 参数a >=5 and 参数a<10 then '中'
else '差' end as 评价
from data
union all
select 'type_b' 类型,
case when 参数b < 25 then '好'
when 参数b >=25 and 参数b<40 then '中'
else '差' end as 评价
from data
)
select 类型,评价,count(*) 条数
from t
group by 类型,评价
------解决方案--------------------
我想到最多的就是动态语句……如果是有后台程序处理的把stad表读进来,再拼接语句,不懂其他方法。