Hi Caroline,
You're welcome. If you do that offten, you may want to create permanent table (instead of crsTemp) filled with records and indexed on Qty which may speed up the query.
>That's brilliant Thanks Sergey.
>Now I've just got to confirm that it's faster with my data!
>Caroline
>>Hi Caroline,
>>
>>You can do that w/o SCAN
SELECT MAX(qty) as MaxQty ;
>> FROM mytable ;
>> INTO ARRAY laMaxQty
>>CREATE CURSOR crsTemp ( Qty I)
>>FOR i=1 TO laMaxQty[1]
>> INSERT INTO crsTemp VALUES (i)
>>ENDFOR
>>
>>SELECT mt.Desc ;
>> FROM mytable mt ;
>> JOIN crsTemp ct ON ct.Qty <= mt.qty ;
>> INTO CURSOR crsResult
>>
--sb--