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

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

博客园 - 李计刚

怎样定制图表提示? SQL学习笔记之ANSI_NULLS 要生就生双胞胎~ 如何手写代码以生成Composite图表? 在重庆访古~ Infragistics控件在VS.net 2005中使用的注意事项 UltraChart中如何自定义标签? 关于ColumnLine Chart 重庆印象! 用图表向导生成ColumnLineChart 在VS2005中调试JavaScript 那些逝去的美好日子! Infragistics中Custom Layer的实现(翻译) UltraChart绑定数据的问题(翻译) 韩剧已不再风光! 用颜色矩阵实现的图象反转效果 关于:GDI+FAQ的好去处! 我做的数字图象处理 我的Blog开通了!
关于SELECT执行顺序的问题!
李计刚 · 2009-05-19 · via 博客园 - 李计刚

最近准备数据库DBA的面试,碰到考察select语句执行顺序的问题,见附,回头查询了下王珊老师的《数据库系统概论》,里面给SELECT的定义格式为:
SELECT[ALL|DISTINCT]<目标列表达式>[,<目标列表达式>]…
FROM<表名或视图名>[,<表名或视图名>]…
[WHERE<条件表达式>]
[GROUP BY<列名1>][HAVING<条件表达式>]
[ORDER BY<列名2>][ASC|DESC]
文中其对SELECT语句的含义解释为:根据where子句的条件表达式,从FROM子句指定的基本表或视图中找出满足条件的元组,再按Select子句中的目标列表达式,选出元组中的属性值形成结果表。如果有GROUP子句,则将结果按<列名1>的值进行分组,该属性列值相等的元组为一个组。通常会在每组中作用集函数(sum,count,max,min等)。如果GROUP子句带HAVING短语,则只有满足指定条件的组才会输出。如果有ORDER子句,则结果表还要按<列名2>的值的升序或降序排序。
我反复体会了好几遍,感觉这样的叙述很容易让人得出SELECT语句执行顺序为:from,where,目标列表达式,group,使用聚集函数计算,having,order的结论,但是这样的执行顺序总感觉特别扭,与所体会的SELECT的用法不那么匹配,通过网络调研,得到如下结果,特分享出来,希望对大家有所帮助:
1、from子句组装来自不同数据源的数据;
2、where子句基于指定的条件对记录行进行筛选;
3、group by子句将数据划分为多个分组;
4、使用聚集函数进行计算;
5、使用having子句筛选分组;
6、计算所有的表达式;
7、使用order by对结果集进行排序。
有了上述这样的认识,我们来做附录上的两到SQL面试题,答案将很容易,分别是E,C
1)in a select statement that includes a where clause,where is the group by clause placed in the select statement?______。
A. immediately after the select clause
B. before the where clause
C. before the from clause
D. after the order by clause
E. after the where clause
2)in a select statement that includes a where clause,where is the order by clause placed in the select statement?______.
A.immediately after the select clause
B.before the where clause
C.after all clause
D.after the where clause
E.before the from clause