Thank you, Sergey.
>It's VFP8 and earlier subquery limitation. Should work fine in VFP9.
>
>>I'm trying to help Dmitry in the 'Can this be done...' thread.
>>
>>It seems like the following SQL statement should do what he wants but it gets the error "Command is missing required clause".
>>
>>
>>select KEYFIELD, CUST_ID as CUSTOMER, ORD_DATE, ORD_TIME ;
>>from ORDERTABLE ;
>>where KEYFIELD in ;
>>(select top 1 KEYFIELD from ORDERTABLE where CUST_ID == CUSTOMER order by ORD_DATE, ORD_TIME descending)
>>order by CUSTOMER
>>
>>
>>The sub-select works fine by itself.
>>
>>I simplified the statement this way but it still gets the error.
>>
>>select ORDERTABLE.KEYFIELD, ORDERTABLE.CUST_ID as CUSTOMER, ORDERTABLE.ORD_DATE, ORDERTABLE.ORD_TIME ;
>>from ORDERTABLE ;
>>where KEYFIELD in ;
>>(select top 1 ORDERTABLE.KEYFIELD from ORDERTABLE order by ORD_TIME )
>>
>>
>>If I substitute ALL for TOP 1, the error goes away.
>>
>>Any ideas?
>>
>>Peter
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham