title: GROUP BY function that returns the first result
body: <p>Here is my MySQL query with its result, I want to obtain for each value of 'function' the first result of 'priority', and thus get the result below</p>
  
  <p>However, a syntax of the type "SELECT function, FIRST (priority) ... GROUP BY function" does not exist, do you have any idea how to do this?</p>
  
  <pre><code>SELECT
    function,
    priority
  FROM challenge_access_rule
  WHERE 10 = challenge_access_rule.challenge_id
        AND (
          rule = 'everybody'
          OR (rule = 'friends' AND 1)
        )
  UNION
  SELECT
    function,
    isRestriction AS priority
  FROM challenge_access_user
  WHERE 10 = challenge_access_user.challenge_id AND challenge_access_user.user_id = 2
  ORDER BY ABS(priority)
  
  -- RESULT --
  emitInstance      |  0
  emitDeal          |  0
  emitDealInstance  |  1
  emitDeal          |  100
  emitDealInstance  |  -100
  vote              |  -100
  emitDeal          |  -200
  view              |  -200
  interact          |  -200
  
  -- DESIRED RESULT --
  emitInstance      |  0
  emitDeal          |  0
  emitDealInstance  |  1
  vote              |  -100
  view              |  -200
  interact          |  -200
  </code></pre>
  
  <p>Thanks,
  Bastien</p>