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

推荐订阅源

Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cisco Blogs
L
LINUX DO - 热门话题
S
Schneier on Security
NISL@THU
NISL@THU
T
Threatpost
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
量子位
Stack Overflow Blog
Stack Overflow Blog
The GitHub Blog
The GitHub Blog
月光博客
月光博客
Cyberwarzone
Cyberwarzone
B
Blog
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Microsoft Security Blog
Microsoft Security Blog
Vercel News
Vercel News
小众软件
小众软件
M
MIT News - Artificial intelligence
I
InfoQ
aimingoo的专栏
aimingoo的专栏
C
CXSECURITY Database RSS Feed - CXSecurity.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
美团技术团队
Google DeepMind News
Google DeepMind News
T
The Blog of Author Tim Ferriss
Help Net Security
Help Net Security
WordPress大学
WordPress大学
V
Vulnerabilities – Threatpost
T
Tenable Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
N
Netflix TechBlog - Medium
MyScale Blog
MyScale Blog
Blog — PlanetScale
Blog — PlanetScale
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
D
Docker
MongoDB | Blog
MongoDB | Blog
Forbes - Security
Forbes - Security
H
Hacker News: Front Page
A
About on SuperTechFans
L
LINUX DO - 最新话题
B
Blog RSS Feed
D
DataBreaches.Net
博客园 - 司徒正美
Recorded Future
Recorded Future
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog

博客园 - 电电儿

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语句具有更清晰的结构。