SQL-Select, 'TOP' Clause

Author: Brad Jones

Posted: 2000-07-12 at 13:15:12

I'm attempting to grab a variable number of records off the top of an

ordered SQL-Select statement. Everything else about the SELECT statement

will be the same.

I will continue trying things but thought I'd throw this e-mail out to

perhaps short-circuit the cycle.

In essence, the following code demonstrates what I'd *like* to do:

SELECT parenttable

SCAN

SELE TOP parenttable.nQty ;

fld1, fld2, fld3 ;

FROM childtable ;

ORDER BY 1

*-- subsequent processing

ENDSCAN

I've tried storing the following three items to variables and then

macro-expanding them as appropriate, but all without success:

"TOP " + TRANS(parenttable.nQty)

"TOP " + TRANS(parenttable.nQty) + " fld1, fld2, fld3"

TRANS(parenttable.nQty)

What they return is *EVERYTHING* from the child table, not the TOP x.

--Brad "I want the TOP x" Jones

©2000 Brad Jones