fork download
  1. create table atable
  2. (A varchar(20),
  3. B int);
  4.  
  5. insert into atable (A,B)
  6. VALUES ('Паша', 5);
  7. insert into atable (A,B)
  8. VALUES ('Cаша', 5);
  9. insert into atable (A,B)
  10. VALUES ('Даша', 5);
  11. insert into atable (A,B)
  12. VALUES ('Маша', 5);
  13.  
  14. select A from atable
  15. ORDER BY B DESC Limit 1;
  16.  
  17. select t.A from atable as t
  18. WHERE not exists (
  19. select t1.A from atable as t1
  20. WHERE t1.B > t.B
  21. ) Limit 1;
Success #stdin #stdout 0s 2964KB
stdin
Standard input is empty
stdout
Паша
Паша