Update assign_alias to use a subquery as asked by postgresql

Currently postgresql complains about the group_by argument and asks that all the
elements in the SELECT also appear in the GROUP BY, which is indeed how it
should be (thanks sqlite!).

With this commit we replace the main query by a subquery so that we can keep the
GROUP BY the way we want and just retrieve the Update object that fits the
Update.id found by the subquery.