Tuesday, February 8, 2011

Dream feature, LIMIT clause on aggregate functions

select student, 
array_to_string( 
    array_agg(grade order by grade desc limit 2), ',' ) as two_best_grades
from 
student_grades
group by student;

No comments:

Post a Comment