>Hi all
>As far as I can tell SQL-SELECT doesn't support ORDER BY ASC for TOP 'n' queries, just DESC. Is there any way to simulate BOTTOM 'n' in a VFP SQL-SELECT line such as:
SELECT TOP 'n' field1 FROM mytable WHERE field1 < lnmyvariable ORDER BY field1 DESC
This may seem like a long shot but maybe there is there a cunning function known only to UT subscribers which inverts character, date or numeric values...worth asking anyhow.
>TIA
>Dick
Dick,
Simple, just select TOP 'N and ORDER (indexname) DESCENDING. Here's an example:
select top 10 * from agents order by agentid descending
THis gives me the bottom 10 agents by agentid, which could be a calculated value. Only then you'd use the field 'nth' position rather than a name in the DESCENDING phrase.
By using the DESCENDING keyword you get the bottom 'n' instead of the top 'n' records.
Hope that helps!
Best,
Best,
DD
A man is no fool who gives up that which he cannot keep for that which he cannot lose.
Everything I don't understand must be easy!
The difficulty of any task is measured by the capacity of the agent performing the work.