惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Project Zero
Project Zero
GbyAI
GbyAI
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
小众软件
小众软件
The GitHub Blog
The GitHub Blog
阮一峰的网络日志
阮一峰的网络日志
J
Java Code Geeks
WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
IT之家
IT之家
F
Fortinet All Blogs
博客园 - 【当耐特】
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Proofpoint News Feed
Schneier on Security
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
Spread Privacy
Spread Privacy
O
OpenAI News
V
V2EX
博客园 - 三生石上(FineUI控件)
AI
AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
P
Privacy International News Feed
Microsoft Azure Blog
Microsoft Azure Blog
Blog — PlanetScale
Blog — PlanetScale
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
H
Help Net Security
L
LINUX DO - 最新话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Tenable Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Cisco Talos Blog
Cisco Talos Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 叶小钗
V
Vulnerabilities – Threatpost
C
Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
酷 壳 – CoolShell
酷 壳 – CoolShell
Hacker News: Ask HN
Hacker News: Ask HN
S
Security @ Cisco Blogs
S
Securelist
T
The Blog of Author Tim Ferriss
Apple Machine Learning Research
Apple Machine Learning Research
美团技术团队
雷峰网
雷峰网
V2EX - 技术
V2EX - 技术

博客园 - 电电儿

FME Cloud 账号申请流程 FME中通过HTMLExtractor向HTML要数据 在windows 2003下安装 django + apache + mod_python arcgis中坐标系统的简单描述 arcgis 中利用txt坐标文件创建要素的办法,含txt文件详细格式~ Django静态文件配置备忘录 【转】ARCSDE+ORACLE备份 测量坐标系中单个多边形面积解析法计算的程序源代码 - 电电儿 - 博客园 System.Data.SQLite测试 oracle左右连接的另外表示方法 Oracle 函数大全(字符串函数,数学函数,日期函数,逻辑运算函数,其他函数) Oracle中的Union、Union All、Intersect、Minus inner join,full outer join,left join,right join,cross join Oracle中的自连接(self join) Oracle 中的natural join (自然连接) ORACLE JOIN 用正则表达式分析正则表达式!求正则表达式组数~ - 电电儿 - 博客园 BoooLee pyretoolkit -- 一个基于python re模块的在线正则表达式测试工具 GDAL 在windows python环境下的安装步骤
测试oracle with as
电电儿 · 2009-09-15 · via 博客园 - 电电儿

为了简化SQL语句,可以将语句分成若干个视图来操作,但是创建的试图将会作为对象保存在数据库中,但经常有一些语句只是临时使用,所以在sql-99规范中有了with as 语句,该语句实质上就是创建临时视图,来帮助你简化语句并使语句结构更清晰更容易阅读。

下面的测试中会用到3张表,courseresults(课程-学生-成绩表)、courses(课程表)、students(学生表),先给出建表语句:

create table COURSERESULTS
(
  CID   NUMBER,
  SID   NUMBER,
  SCORE FLOAT not null
)

create table COURSES
(
  CID     NUMBER not null,
  CNAME   VARCHAR2(100) not null,
  TID     NUMBER,
  CREDITS NUMBER not null
)

create table STUDENTS
(
  SID       NUMBER not null,
  SNAME     VARCHAR2(50) not null,
  SEX       CHAR(1),
  BIRTHDATE DATE,
  EMAIL     VARCHAR2(50)
)

例1:获取student表全部数据

with s as

(select * from students)

select * from s;

例2:获取小于平均成绩的学生学号和成绩

with c as
(select avg(score) as value from courseresults)
select sid,score from courseresults,c where score>c.value;

例3:获取课程平均成绩大于85分的男生的学号

with
s1 as
(select sid from courseresults group by sid having avg(score)>85),
s2 as
(select sid from students where sex='m')
select * from s1 intersect select * from s2;

结论:使用with as语句的确可以使复杂的SQL语句具有更清晰的结构。