Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Rank code
Message
 
 
À
25/09/2008 09:50:30
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows 2008 Server
Database:
Visual FoxPro
Divers
Thread ID:
01350486
Message ID:
01350544
Vues:
24
>(1) I do not check other subjects - as mentioned in my answer
>(2) I do relate by Total - not by Id
>

Yes, I'm just telling that your solution should be expanded, e.g. you need to add group by all subjects in the order of importance and in the UPDATE statement use

INNER JOIN on Rank.Total = Tmp.Total and Rank.Math = Tmp.Math and ... etc.

It may be bad performance wise, but it meets exact requirements.

>________
>>Hi Gregory,
>>
>>The original requirement was to check other subjects, so you need to group by total, by total in English, in math, etc., but the idea seems to work. In other words, you need to relate based on score, not by ID.
>>
>>>>This doesn't account for absolute ties (same scores in all subjects).
>>>>
>>>The only way to do that is to work with a group by
>>>
>>>This is what I had - but works only on ties with the total score -
>>>
>>>create cursor test ;
>>>	(	Student	I, ;
>>>		English	I, ;
>>>		Maths	I, ;
>>>		Science	I, ;
>>>		Total	I, ;
>>>		Rank	I ;
>>>	)
>>>	
>>>	insert into test values(5, 0,0,0, 489, 0)
>>>	insert into test values(4, 0,0,0, 492, 0)
>>>	insert into test values(3, 0,0,0, 391, 0)
>>>	insert into test values(2, 0,0,0, 391, 0)
>>>	insert into test values(1, 0,0,0, 389, 0)
>>>	
>>>	select	cast(0 as I)	as RankTmp,;
>>>			Total ;
>>>		from test ;
>>>		into cursor tmp ReadWrite ;
>>>		group by 1, 2 ;
>>>		order by 1 desc, 2 desc	
>>>	
>>>	repl Ranktmp with recno() all in tmp
>>>	
>>>	update test ;
>>>		set Rank = tmp.RankTmp ;
>>>			from tmp ;
>>>			where (test.Total == tmp.Total )
>>>	
>>>	selec * from Test order by Rank
>>>
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