Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

SQL:Temukan rekor maksimum per grup

select
  Name, Top, Total
from
  sometable
where
  Total = (select max(Total) from sometable i where i.Name = sometable.Name)

atau

select
  Name, Top, Total
from
  sometable
  inner join (
    select max(Total) Total, Name
    from sometable
    group by Name
  ) as max on max.Name = sometable.Name and max.Total = sometable.Total


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. AVG() – Menghitung Nilai Rata-Rata Kolom di MySQL

  2. Host lokal mysql !=127.0.0.1?

  3. Bagaimana cara mengisi lubang di bidang kenaikan otomatis?

  4. Bagaimana menjalankan skrip SQL di MySQL?

  5. Memperbarui dari MYSQL ke MYSQLI