title: SQL/Presto: how to rank within a subgroup of each group
body: <p>I have a table like the following:</p>
  <pre><code>group_id  sub_group_id   user_id score  time
  1          a1            ann      1     2019
  1          a1            bob      1     2020
  1          a2            cat      0     2020
  2          b1            dan      0     2019
  2          b1            eva      0     2019
  2          b1            ed       1     2020
  2          b2            liz      1     2020
  </code></pre>
  <p>i want to rank user_id within subgroup of each group by the score and then by time (earlier better) each user_id gets. so the desired output is</p>
  <pre><code>group_id  sub_group_id   user_id score   time  rank
  1          a1            ann      1      2019  1
  1          a1            bob      1      2020  2
  1          a2            cat      0      2020  1
  2          b1            dan      0      2019  1
  2          b1            eva      0      2019  1
  2          b1            ed       1      2020  2
  2          b2            liz      1      2020  1
  </code></pre>