<i id='cT2Qu'><tr id='cT2Qu'><dt id='cT2Qu'><q id='cT2Qu'><span id='cT2Qu'><b id='cT2Qu'><form id='cT2Qu'><ins id='cT2Qu'></ins><ul id='cT2Qu'></ul><sub id='cT2Qu'></sub></form><legend id='cT2Qu'></legend><bdo id='cT2Qu'><pre id='cT2Qu'><center id='cT2Qu'></center></pre></bdo></b><th id='cT2Qu'></th></span></q></dt></tr></i><div id='cT2Qu'><tfoot id='cT2Qu'></tfoot><dl id='cT2Qu'><fieldset id='cT2Qu'></fieldset></dl></div>

    • <bdo id='cT2Qu'></bdo><ul id='cT2Qu'></ul>

    <small id='cT2Qu'></small><noframes id='cT2Qu'>

  1. <tfoot id='cT2Qu'></tfoot>

    1. <legend id='cT2Qu'><style id='cT2Qu'><dir id='cT2Qu'><q id='cT2Qu'></q></dir></style></legend>

      为什么 Oracle SQL 不允许我们在 GROUP BY 子句中使用列别名?

      Why doesn#39;t Oracle SQL allow us to use column aliases in GROUP BY clauses?(为什么 Oracle SQL 不允许我们在 GROUP BY 子句中使用列别名?)
    2. <i id='swr8y'><tr id='swr8y'><dt id='swr8y'><q id='swr8y'><span id='swr8y'><b id='swr8y'><form id='swr8y'><ins id='swr8y'></ins><ul id='swr8y'></ul><sub id='swr8y'></sub></form><legend id='swr8y'></legend><bdo id='swr8y'><pre id='swr8y'><center id='swr8y'></center></pre></bdo></b><th id='swr8y'></th></span></q></dt></tr></i><div id='swr8y'><tfoot id='swr8y'></tfoot><dl id='swr8y'><fieldset id='swr8y'></fieldset></dl></div>

      • <bdo id='swr8y'></bdo><ul id='swr8y'></ul>

          <tfoot id='swr8y'></tfoot>
                  <tbody id='swr8y'></tbody>

                <small id='swr8y'></small><noframes id='swr8y'>

                <legend id='swr8y'><style id='swr8y'><dir id='swr8y'><q id='swr8y'></q></dir></style></legend>
                本文介绍了为什么 Oracle SQL 不允许我们在 GROUP BY 子句中使用列别名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                这是我在编写 SQL 查询时通常面临的情况.我认为在 GROUP BY 表达式中编写整列(例如长 case 表达式、长参数求和函数)而不是别名会使查询更长且可读性更低.为什么 Oracle SQL 不允许我们在 GROUP BY 子句中使用列别名?这背后一定有重要的原因.

                This is a situation I'm generally facing while writing SQL queries. I think that writing the whole column (e.g. long case expressions, sum functions with long parameters) instead of aliases in GROUP BY expressions makes the query longer and less readable. Why doesn't Oracle SQL allow us to use the column aliases in GROUP BY clause? There must be an important reason behind it.

                推荐答案

                它不仅仅是 Oracle SQL,事实上我相信它符合 ANSI SQL 标准(尽管我没有参考).原因是 SELECT 子句在 GROUP BY 子句之后进行逻辑处理,因此在 GROUP BY 完成时,别名还不存在.

                It isn't just Oracle SQL, in fact I believe it is conforming to the ANSI SQL standard (though I don't have a reference for that). The reason is that the SELECT clause is logically processed after the GROUP BY clause, so at the time the GROUP BY is done the aliases don't yet exist.

                也许这个有点荒谬的例子有助于澄清问题和 SQL 避免的歧义:

                Perhaps this somewhat ridiculous example helps clarify the issue and the ambiguity that SQL is avoiding:

                SQL> select job as sal, sum(sal) as job
                  2  from scott.emp
                  3  group by job;
                
                SAL              JOB
                --------- ----------
                ANALYST         6000
                CLERK           4150
                MANAGER         8275
                PRESIDENT       5000
                SALESMAN        5600
                

                这篇关于为什么 Oracle SQL 不允许我们在 GROUP BY 子句中使用列别名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                SQL query to group by day(按天分组的 SQL 查询)
                What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                Include missing months in Group By query(在 Group By 查询中包含缺失的月份)
              • <tfoot id='6cuzq'></tfoot>

                      <tbody id='6cuzq'></tbody>
                    <i id='6cuzq'><tr id='6cuzq'><dt id='6cuzq'><q id='6cuzq'><span id='6cuzq'><b id='6cuzq'><form id='6cuzq'><ins id='6cuzq'></ins><ul id='6cuzq'></ul><sub id='6cuzq'></sub></form><legend id='6cuzq'></legend><bdo id='6cuzq'><pre id='6cuzq'><center id='6cuzq'></center></pre></bdo></b><th id='6cuzq'></th></span></q></dt></tr></i><div id='6cuzq'><tfoot id='6cuzq'></tfoot><dl id='6cuzq'><fieldset id='6cuzq'></fieldset></dl></div>

                    <small id='6cuzq'></small><noframes id='6cuzq'>

                      <bdo id='6cuzq'></bdo><ul id='6cuzq'></ul>
                      • <legend id='6cuzq'><style id='6cuzq'><dir id='6cuzq'><q id='6cuzq'></q></dir></style></legend>