zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Nginx 的 server_names_hash_bucket_size 问题
    Linux 查看CPU信息、机器型号等硬件信息
    JS中的prototype[转载]
    memcache适用和不适用场景[转载]
    php的socket通信【转载】
    fastcgi与cgi的区别[转载]
    PHP类和对象
    SVN的配置和使用
    PHP_pear的安装和使用
    [转]Python tips: 什么是*args和**kwargs?
  • 原文地址:https://www.cnblogs.com/wyj1212/p/8623318.html
Copyright © 2011-2022 走看看