Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rank code
Message
 
 
To
25/09/2008 09:50:30
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows 2008 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01350486
Message ID:
01350544
Views:
25
>(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
Previous
Reply
Map
View

Click here to load this message in the networking platform