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

Primi n percento Primi n%

Puoi provare questo:

WITH     got_analytics     AS
(
     SELECT     ssn, gpa
     ,     ROW_NUMBER () OVER (ORDER BY  gpa  DESC)     AS r_num
     ,     COUNT (*)     OVER ()                                AS n_rows 
     FROM  student_gpa   
)
SELECT       ssn, gpa
FROM       got_analytics 
WHERE       r_num     <= ROUND (n_rows * 12/*insert here your n%*/ / 100)
ORDER BY  gpa     DESC