PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Extracting top five only for each group
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Extracting top five only for each group

Réponse
 
LinkBack Outils de la discussion
Vieux 18/04/2008, 10h02   #1
andrew_d_may@hotmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Extracting top five only for each group

A have a table, a classic student test result table that contains
StudentID, TestID and Score. For any student there can be any number
of scores, including zero, for any given test. For a given student I
want to extract the scores for each test and am using:

Select * from Results where StudentId=x order by TestID, Score;

This returns all the results for a given student and works fine. What
I really want to do though is to only return the top five scores for
_each_ test.

I am sure this is easy and am guessing that this requires some form of
select from (select from ...) syntax but cannot work out what.

Could some kind soul please point me in the right direction?

Andrew
  Réponse avec citation
Vieux 18/04/2008, 16h01   #2
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Extracting top five only for each group

On 18 Apr, 09:02, "andrew_d_...@hotmail.com"
<andrew_d_...@hotmail.com> wrote:
> A have a table, a classic student test result table that contains
> StudentID, TestID and Score. For any student there can be any number
> of scores, including zero, for any given test. For a given student I
> want to extract the scores for each test and am using:
>
> Select * from Results where StudentId=x order by TestID, Score;
>
> This returns all the results for a given student and works fine. What
> I really want to do though is to only return the top five scores for
> _each_ test.
>
> I am sure this is easy and am guessing that this requires some form of
> select from (select from ...) syntax but cannot work out what.
>
> Could some kind soul please point me in the right direction?
>
> Andrew


There are just SO MANY answers around to this already!
I just Googled "mysql top n group" and got a massive list.
Here's a link to the first one:

http://thenoyes.com/littlenoise/?p=36
  Réponse avec citation
Vieux 18/04/2008, 16h27   #3
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Extracting top five only for each group

On 18 Apr, 09:02, "andrew_d_...@hotmail.com"
<andrew_d_...@hotmail.com> wrote:
> A have a table, a classic student test result table that contains
> StudentID, TestID and Score. For any student there can be any number
> of scores, including zero, for any given test. For a given student I
> want to extract the scores for each test and am using:
>
> Select * from Results where StudentId=x order by TestID, Score;
>
> This returns all the results for a given student and works fine. What
> I really want to do though is to only return the top five scores for
> _each_ test.
>
> I am sure this is easy and am guessing that this requires some form of
> select from (select from ...) syntax but cannot work out what.
>
> Could some kind soul please point me in the right direction?
>
> Andrew


There are just SO MANY answers around to this already!
I just Googled "mysql top n group" and got a massive list.
Here's a link to the first one:

http://thenoyes.com/littlenoise/?p=36
  Réponse avec citation
Vieux 21/04/2008, 00h14   #4
andrew_d_may@hotmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Extracting top five only for each group

On 18 Apr, 16:27, Captain Paralytic <paul_laut...@yahoo.com> wrote:

> There are just SO MANY answers around to this already!
> I just Googled "mysql top n group" and got a massive list.
> Here's a link to the first one:
>
> http://thenoyes.com/littlenoise/?p=36


Thank you. That was the pointer that I needed. I was missing the
'group' in the search terms.

Andrew

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 21h25.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,23260 seconds with 12 queries