Oracle
 sql >> Teknologi Basis Data >  >> RDS >> Oracle

Maksimum rata-rata

Tanpa CTE, Anda dapat melakukan:

Select Z.Department, Z.AvgWage
From  (
        Select Department, Avg(Wage) AvgWage
        From Employees
        Group By Department
        ) As Z
Where AvgWage = (
                Select Max(Z1.AvgWage)
                From    (
                        Select Department, Avg(Wage) AvgWage
                        From Employees
                        Group By Department
                        )  Z1
                )

Dengan CTE, Anda dapat melakukan:

With AvgWages As
    (
    Select Department
        , Avg(Wage) AvgWage
        , Rank() Over( Order By Avg(Wage) Desc ) WageRank
    From Employees
    Group By Department
    )
Select Department, AvgWage, WageRank
From AvgWages
Where WageRank = 1


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Bagaimana cara menyinkronkan dan mengoptimalkan indeks Oracle Text?

  2. SQL menghitung frekuensi item menggunakan beberapa/kolom dependen?

  3. SYS_EXTRACT_UTC() Fungsi di Oracle

  4. Panggilan Terjebak ke fungsi yang tidak ditentukan oci_connect() menggunakan XAMPP

  5. Langkah-langkah untuk menyinkronkan Siaga dengan Basis Data Utama di Oracle