Alexander Farber wrote:

> Here is such a query for the best player
> 
> # SELECT AVG(score) FROM words_moves WHERE uid = 1201;
>         avg
> ---------------------
> 18.4803525523319868
> 
> However I am not sure, how to "marry" the 2 queries?
> 
> I have tried to add words_moves through another JOIN, but that does not
> work:

You may use a correlated subquery in the SELECT clause,
like this:

 SELECT
       u.elo,
       u.uid,
       (SELECT AVG(score) FROM words_moves WHERE uid=u.uid),
       s.given,
       s.photo


Best regards,
-- 
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite

Reply via email to