fork(1) download
  1. create table table_avg (
  2. nickname varchar(10),
  3. AVG_RESPONSETIME int);
  4.  
  5. insert into table_avg values ('cyber426',1);
  6. insert into table_avg values ('neo927',1);
  7. insert into table_avg values ('neo259',3);
  8. insert into table_avg values ('cypher15',4);
  9. insert into table_avg values ('fool28',5);
  10. insert into table_avg values ('cyber974',6);
  11. insert into table_avg values ('hacker285',6);
  12. insert into table_avg values ('dau719',7);
  13. insert into table_avg values ('trinity407',7);
  14. insert into table_avg values ('fool380',8);
  15. insert into table_avg values ('wiesel509',8);
  16. insert into table_avg values ('dau814',10);
  17. insert into table_avg values ('morpheus462',10);
  18. insert into table_avg values ('neo517',10);
  19. insert into table_avg values ('drago831',11);
  20. insert into table_avg values ('drago861',13);
  21.  
  22.  
  23. SELECT a.NICKNAME,
  24. a.AVG_RESPONSETIME,
  25. count(b.AVG_RESPONSETIME) + 1 - count(case (a.AVG_RESPONSETIME - b.AVG_RESPONSETIME) when 0 then 1 else NULL end) as rank
  26. FROM table_avg a,
  27. table_avg b
  28. WHERE b.AVG_RESPONSETIME<=a.AVG_RESPONSETIME
  29. GROUP BY a.NICKNAME,
  30. a.AVG_RESPONSETIME HAVING count(b.AVG_RESPONSETIME) <=10
  31. ORDER BY RANK ASC,
  32. a.NICKNAME ASC;
  33.  
Success #stdin #stdout 0s 3008KB
stdin
Standard input is empty
stdout
cyber426|1|1
neo927|1|1
neo259|3|3
cypher15|4|4
fool28|5|5
cyber974|6|6
hacker285|6|6
dau719|7|8
trinity407|7|8