sql >> Database teknologi >  >> RDS >> Oracle

ORA-00934:Gruppefunktion ikke tilladt her || Valg af MIN(Løn) for højest betalte afd

Jeg kan ikke teste dette, men det burde virke:

;WITH DepartmentsSalary AS
(
    SELECT department_ID, AVG(Salary) AvgSalary, MIN(Salary) MinSalary
    FROM employees
    GROUP BY department_ID
)
SELECT department_ID, MinSalary
FROM (  SELECT department_ID, AvgSalary, MAX(AvgSalary) OVER() MaxSalary, MinSalary
        FROM DepartmentsSalary) D
WHERE MaxSalary = AvgSalary


  1. UNDTAGET ALLE tilsvarende i MySQL

  2. Oracle SQL Regexp_replace matching

  3. SQL SELECT hastighed int vs varchar

  4. Visual Studio 2008/2010 &SQL Server 2008 på Windows 7 Home Premium