with temp as(
select '张三' name,'优' score from dual
union all
select '张三' name,'优' score from dual
union all
select '张三' name,'良' score from dual
union all
select '张三' name,'良' score from dual
union all
select '张三' name,'及格' score from dual
union all
select '李四' name,'优' score from dual
union all
select '李四' name,'良' score from dual
union all
select '李四' name,'良' score from dual
union all
select '李四' name,'良' score from dual
union all
select '李四' name,'及格' score from dual
union all
select '李四' name,'及格' score from dual
)
select name,
sum(decode(score,'优',1)) as "优",
sum(decode(score,'良',1)) as "良",
sum(decode(score,'及格',1)) as "及格"
from temp
group by name
列转行
最新推荐文章于 2019-02-22 18:50:49 发布