create view t_myuser as
select
ooo.*,
decode(sign((select avg(score)-struts from t_user_score where ke='struts')),1,'是的,低于平均分',-1,'高于平均分','跟平均分持平') low_struts_avg,
decode(sign((select avg(score)-spring from t_user_score where ke='spring')),1,'是的,低于平均分',-1,'高于平均分','跟平均分持平') low_srping_avg,
decode(sign((select avg(score)-hibernate from t_user_score where ke='hibernate')),1,'是的,低于平均分',-1,'高于平均分','跟平均分持平') low_hibernate_avg,
decode(sign((select avg(score)-oracle from t_user_score where ke='oracle')),1,'是的,低于平均分',-1,'高于平均分','跟平均分持平') low_oracle_avg
from (
select * from (
(select user_name,ke,score from t_user_score)
)
pivot(
sum(score) -- 统计值
for ke in ('struts' as struts,'spring' as spring,'hibernate' as hibernate,'oracle' as oracle) -- 划分多少列
)
) ooo
select * from t_user_score
-- 查询简单多了
select * from t_myuser
-- 条件查询
select * from t_myuser where spring<40
--试图view,数据能改吗?
update t_myuser set struts=81 where spring<40
update t_myuser set user_name='小陈' where spring<40
select * from t_user_score
select rowid,user_name from t_myuser