Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL help
Message
From
17/04/2005 02:23:35
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
01005535
Message ID:
01005544
Views:
16
>VFP 9. Have a row of house sales with four columns. The fields are listed below. Sales year and month are character fields. I want all four columns returned for the most recent sale for each unique houseid.
>
>Table Fields
>houseid, sales month, sales year, sale amount,
>
>Thanks
>
>Brenda

How about???
SELECT houseid,MAX(sales_year + sales_month) AS mo;
 FROM myTable;
 GROUP BY 1;
 INTO CURSOR curTemp

SELECT myTable.*;
 FROM myTable,curTemp;
 WHERE myTable.houseid = curTemp.houseid;
   AND myTable.sales_year + myTable.sales_month = curTemp.mo
Bear in mind that if you have multiple records for a year/month combination, you will get multiple rows returned in the final result.
Previous
Reply
Map
View

Click here to load this message in the networking platform