oracle with as 用法

发布时间:2020-06-15 21:44:44 作者:姚小二
来源:网络 阅读:6337

With查询语句已with开头,相当于在查询之前先构建一个临时表,被指定的查询结果存与临时表中,之后便可多次使用它做进一步的分析和处理。


语法:

with _tempTable as (select * from table )
select  * from _tempTable



例子:

with _tempStudent as(
select * from t_student t where class = '初二3班'
)
select sex,count(1) nums from _tempStudent where sex = '男' and height > '170'
union all
select sex,count(1) nums from _tempStudent where sex = '女' and height > '160'


多个with as 用法 每个临时存量直接用 "," 隔开

with t1 as (
     select * from student where name in('张三','李四')
),t2 as (
     select * from student where name in('王五')
)
select * from t1
union 
select * from t2


如果with as 有嵌套的情况, 多个with as,后面的as内部可以直接调用先声明的临时对象

with t1 as (
     select * from student where name in('张三','李四')
),t2 as (
     select * from t1 where name in('王五')
)
select * from t2


推荐阅读:
  1. Oracle 采用logmnr 分析在线redo日志
  2. ibatis结合oracle批量插入三种方法的测评

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

oracle with as

上一篇:GPU应用程序Attach调试记录

下一篇:配置数据库读写分离服务器

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》