Select top 10 in progress

jmac13

Member
Hi guys,


In sql you can do a select top 10 * from ttExample to get the top 10 records etc from a table

is there an equivalent in progress? or do i have to put a count in my for each then when its reached leave it?


Thanks
 
FOR EACH supports WHILE - but yes you will need to count your results. Be sure to order your query to produce the top 10.

Code:
DEFINE TEMP-TABLE tt FIELD ii AS INT.


DEF VAR ii AS INT NO-UNDO.


DO ii = 1 TO 100:
   CREATE tt. tt.ii = RANDOM( 0, 100 ).
END.
   
ii = 0.
FOR EACH tt 
   BY tt.ii DESCENDING 
   WHILE ii < 10:


   DISPLAY tt.ii. 
   
   ii = ii + 1.


END.

I hate LEAVE, I love WHILE.
 
Back
Top