• ORACLE1.19-视图view的应用


    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

  • 相关阅读:
    VScode 关闭回车后自动格式化代码
    『转载』专利申请
    『转载』 免费公用DNS服务及三大运营商DNS大全 含IPV4和IPV6
    正则表达式和元字符
    随机背景图
    秒表
    数组相关的函数
    对象的结构语法
    数组的结构语法
    展开合并运算符
  • 原文地址:https://www.cnblogs.com/wyj1212/p/8623318.html
Copyright © 2020-2023  润新知