Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Returning tables and sets
11. Exercise 3


Good stuff! Let's move on to the next exercise.


Create a new function named get_users_of_three_best_answers() that returns a table with the top three users with the best answers. The result should contain the following columns:

  • user_id int.
  • user_name varchar.
  • count_of_answers bigint.

The final table returned by the function should be sorted by number of answers in descending order and by the ID of user in ascending order.

Stuck? Here's a hint!

You can use RETURNS TABLE along with the RETURN QUERY statement.