Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get Max and Min score
Message
 
 
À
06/04/2007 07:59:39
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01212837
Message ID:
01212924
Vues:
14
>>>>>
>>>>>select * from tests t1 ;
>>>>>	where ;
>>>>>	score = (select min(score) from tests t2 where t1.student = t2.student) ;
>>>>>	or ;
>>>>>	score = (select max(score) from tests t2 where t1.student = t2.student)
>>>>>
>>>>>* Not in older versions
>>>>>select t1.* from tests t1 ;
>>>>>	INNER join ;
>>>>>	(select student, max(score) as maxScore, min(score) as minScore ;
>>>>>	from tests group by 1) t2 ;
>>>>>	on t1.student = t2.student and (t1.score = t2.maxScore or t1.score = t2.minScore)
>>>>>
Cetin
>>>>
>>>>The last one is nice, but should you also group by testname in both cases?
>>>
>>>No. Read the question.
>>>Cetin
>>
>>Well, for this particular data sample we don't need to group by testname. If we would have chem 5 and math 0, we would.
>
>It's not related to data sample, it's related to the wanted result. That's how SQL works. Different needs, different SQL.
>Cetin

Then we're reading the question differently.

Anyway, it's not the first time when I showed I don't know how to read.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform