MySQL Forums
Forum List  »  French

Re: Equivalent d'un LIMIT dans une sous requete
Posted by: Huu Da Tran
Date: May 26, 2008 12:23PM

Est-ce que les données sont trop immenses pour passer par une table temporaire?
create temporary table `tmp_journee_points` (
    `journee_id` int,
    `user_id` int,
    `points` int,
    `idx` int auto_increment,
    primary key (`user_id`, `idx`)
insert into `tmp_journee_points` (`journee_id`, `user_id`, `points`)
    select `journee_id`, `user_id`, `points`
    from `journee_points`
    order by `points` DESC;
select avg(j1.`points`) as 'moyenne',
    j1.`user_id` as 'user_id'
from `journee` as j1
    left join (
      select les 15 meilleures journées par joueur
    ) as j2 on (j1.`user_id` = j2.`user_id` and j2.idx <= 15)

Options: ReplyQuote

Written By
Re: Equivalent d'un LIMIT dans une sous requete
May 26, 2008 12:23PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.