<tfoot id='eRHP6'></tfoot>

<legend id='eRHP6'><style id='eRHP6'><dir id='eRHP6'><q id='eRHP6'></q></dir></style></legend>

    1. <small id='eRHP6'></small><noframes id='eRHP6'>

        • <bdo id='eRHP6'></bdo><ul id='eRHP6'></ul>
      1. <i id='eRHP6'><tr id='eRHP6'><dt id='eRHP6'><q id='eRHP6'><span id='eRHP6'><b id='eRHP6'><form id='eRHP6'><ins id='eRHP6'></ins><ul id='eRHP6'></ul><sub id='eRHP6'></sub></form><legend id='eRHP6'></legend><bdo id='eRHP6'><pre id='eRHP6'><center id='eRHP6'></center></pre></bdo></b><th id='eRHP6'></th></span></q></dt></tr></i><div id='eRHP6'><tfoot id='eRHP6'></tfoot><dl id='eRHP6'><fieldset id='eRHP6'></fieldset></dl></div>
      2. Oracle 显示高于其部门平均工资的所有员工

        Oracle show all employees with greater than average salary of their department(Oracle 显示高于其部门平均工资的所有员工)

            <tbody id='4wQUm'></tbody>
          <legend id='4wQUm'><style id='4wQUm'><dir id='4wQUm'><q id='4wQUm'></q></dir></style></legend>
        1. <tfoot id='4wQUm'></tfoot>

            <small id='4wQUm'></small><noframes id='4wQUm'>

            1. <i id='4wQUm'><tr id='4wQUm'><dt id='4wQUm'><q id='4wQUm'><span id='4wQUm'><b id='4wQUm'><form id='4wQUm'><ins id='4wQUm'></ins><ul id='4wQUm'></ul><sub id='4wQUm'></sub></form><legend id='4wQUm'></legend><bdo id='4wQUm'><pre id='4wQUm'><center id='4wQUm'></center></pre></bdo></b><th id='4wQUm'></th></span></q></dt></tr></i><div id='4wQUm'><tfoot id='4wQUm'></tfoot><dl id='4wQUm'><fieldset id='4wQUm'></fieldset></dl></div>
                  <bdo id='4wQUm'></bdo><ul id='4wQUm'></ul>
                  本文介绍了Oracle 显示高于其部门平均工资的所有员工的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在编写查询以查找收入高于其部门平均工资的员工.我需要显示该部门的员工 ID、工资、部门 ID 和平均工资.

                  I am writing a query to find employees who earn greater than the average salary within their department. I need to display the employee ID, salary, department id, and average salary of that department.

                  我有一个几乎可以正常工作的查询,但它一直给我ORA-00904:AVG_SAL":无效标识符"错误.我这样做是否正确.为什么我会收到此无效标识符错误?

                  I have a query that just almost works but it keeps giving me "ORA-00904: "AVG_SAL": invalid identifier" errors. Am I doing this correctly. Why am i getting this invalid identifier error?

                  SELECT employee_id, salary, department_id,
                    (SELECT ROUND(AVG(salary),2)
                    FROM employees e_inner
                    WHERE e_inner.department_id = e.department_id) AS avg_sal
                  FROM employees e
                  WHERE salary > avg_sal
                  ORDER BY avg_sal DESC
                  

                  推荐答案

                  我不相信您可以在 WHERE 子句中引用列别名(在本例中为 avg_sal).

                  I don't believe you can refer to a column alias (avg_sal in this case) in a WHERE clause.

                  您需要重复该内部查询,即:

                  You'll need to repeat that inner query, i.e.:

                  SELECT employee_id, salary, department_id,
                    (SELECT ROUND(AVG(salary),2)
                    FROM employees e_inner
                    WHERE e_inner.department_id = e.department_id) AS avg_sal
                  FROM employees e
                  WHERE salary > 
                   (SELECT ROUND(AVG(salary),2)
                    FROM employees e_inner
                    WHERE e_inner.department_id = e.department_id)
                  ORDER BY avg_sal DESC
                  

                  这两个内部查询不是很好,但这是纠正错误的最直接的方法.

                  Not great, with those two inner queries, but that's the most-straightforward way to correct the error.

                  更新:尚未对此进行测试,但请尝试以下操作:

                  Update: Haven't tested this, but try the following:

                  SELECT e.employee_id, e.salary, e.department_id, b.avg_sal
                  FROM employees e
                  INNER JOIN
                  (SELECT department_id, ROUND(AVG(salary),2) AS avg_sal
                   FROM employees
                   GROUP BY department_id) e_avg ON e.department_id = e_avg.department_id AND e.salary > e_avg.avg_sal
                  ORDER BY e_avg.avg_sal DESC
                  

                  这篇关于Oracle 显示高于其部门平均工资的所有员工的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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='mhABP'></tfoot>
                    <bdo id='mhABP'></bdo><ul id='mhABP'></ul>
                    <i id='mhABP'><tr id='mhABP'><dt id='mhABP'><q id='mhABP'><span id='mhABP'><b id='mhABP'><form id='mhABP'><ins id='mhABP'></ins><ul id='mhABP'></ul><sub id='mhABP'></sub></form><legend id='mhABP'></legend><bdo id='mhABP'><pre id='mhABP'><center id='mhABP'></center></pre></bdo></b><th id='mhABP'></th></span></q></dt></tr></i><div id='mhABP'><tfoot id='mhABP'></tfoot><dl id='mhABP'><fieldset id='mhABP'></fieldset></dl></div>

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

                        <legend id='mhABP'><style id='mhABP'><dir id='mhABP'><q id='mhABP'></q></dir></style></legend>

                            <tbody id='mhABP'></tbody>