Welcome! Log In Create A New Profile

Advanced

Query or View or ?

Posted by John Marrone 
John Marrone
Query or View or ?
December 23, 2008 06:44PM
Hi All

I need to get a view or query that will return 10 to 20 records. I need to sort on a field in ascending order and then in another field put a 1 , 2, 3 so forth so I know how they ranked. What I would like is suggestion on rather I should use a view or a query or what ever. I need to do this real quick because I will be doing about 20 fields and I don't really want this to be to time consuming. So does anybody know or have an an ideal of the best approach to quickly retrieve 20 records from a table, sort them and then rank them in an other field of the record. This will be of great help.

This is how I do it now. Is this a good way or is there a better way.


<code>
// Rank PowerRating
HCreateView(vwEntries, Entries, "RaceID,PowerRating,RPowerRating", "-PowerRating", "RaceID='"+parRaceID+"'", hViewLocking)
HReadFirst(vwEntries)
vnRanking = 0
WHILE NOT HOut()
// Insert your process here
IF vwEntries.PowerRating > 0 THEN vnRanking++
vwEntries.RPowerRating = vnRanking
HModify(vwEntries)
HReadNext(vwEntries)
END
HViewToFile(vwEntries)
HDeleteView(vwEntries)
</code>



Edited 1 time(s). Last edit at 12/24/2008 03:05AM by John Marrone.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: