So if I have a DB like this:
uid grade 1 8 2 7 3 9 4 3 1 5 2 3 3 2 4 1
How can I get a query that will return the UID with the HIGHEST AVERAGE GRADE?
select uid, avg(grade) g from t group by uid order by g desc fetch 1 row only
Change table name as apropriate.
Depending on which DBMS you are using you may need to change the fetch clause.
Thanks!