Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stumped: sub-select with TOP
Message
From
08/02/2005 17:50:09
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00984923
Message ID:
00984966
Views:
23
>The TOP clause must have GROUP BY. Which I added in the subquery but it still gives me an error.

I believe that is misinformation. I've never used it that way.

Looks like you will have to create a user-defined function to solve your problem until VFP9 gets here.
select KEYFIELD, CUST_ID, ORD_DATE, ORD_TIME 	;
from ORDERTABLE					;
where KEYFIELD == GetLatestOrderKey(CUST_ID)	;
order by CUSTOMER

procedure GetLatestOrderKey
lparameter	tcCUST_ID
local array	laKeys[1]	
select top 1 KEYFIELD from ORDERTABLE 		;
where CUST_ID == tcCUST_ID			;
order by ORD_DATE, ORD_TIME descending		;
into array laKeys
return laKeys[1]
I tested this.

>Thank you for your help.

Always glad to pay back for all the good help I get here.

Peter
Peter Robinson ** Rodes Design ** Virginia
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform