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

  • 相关阅读:
    排序——插入排序
    利用socket传文件
    Segmentation fault (core dumped)
    Linux网络编程
    3G功能设计及实现
    rpm命令
    安装包相互依赖的问题
    centos网站(一些软件的下载)
    解决vim显示中文的问题
    glGetFloatv (GL_MODELVIEW_MATRIX, mat)
  • 原文地址:https://www.cnblogs.com/wyj1212/p/8623318.html
Copyright © 2011-2022 走看看