Author: Jean Laeremans
Posted: 2009-03-12 at 15:16:34
On Thu, Mar 12, 2009 at 8:20 PM, MB Software Solutions General Account
<mbsoftwaresolutions@mbsoftwaresolutions.com> wrote:
> On Thu, March 12, 2009 3:09 pm, Stephen Russell wrote:
>> On Thu, Mar 12, 2009 at 1:58 PM, KAM.covad
>> <a_gmail_noSpam@kenmcginnis.com> wrote:
>>
>>> I have a table with a date field: dDate and thousands of records.
>>>
>>>
>>> The dates are scattered over time including the future. I need to find
>>> the record with the max date that is =3D< required date.
>>>
>>> How would you do this with sql select and also with Locate?
>>>
>> ------------------------
>>
>>
>> Select top 1 <column list>
>> from yourTable where dDate <=3D ldDate order by dDate descending
>>
>> For Fox 7 and higher I believe, maybe you need 8??
>
>
> Not sure, but I'm pretty sure TOP 1 was in VFP 5/6? =A0That's pretty basi=
c.
>
SELECT [ ALL | DISTINCT ]
[ TOP nHowMany [ PERCENT ] ]
eColumn1 [ AS ColumnName1 ]
[, eColumn2 [ AS ColumnName2 ] ... ]
FROM [ FORCE ]
[ Database1! ]Table1 [ LocalAlias1 ]
[ [ INNER | LEFT [ OUTER ] | RIGHT [ OUTER ]
| FULL [ OUTER ] ] JOIN
[ Database2! ]Table2 [ LocalAlias2 ]
[ ... ]
[ ON lJoinCondition1 ]
| , [ Database3! ]Table3 [ LocalAlias3 ]
[ ... ] ]
[ WHERE lConditions ]
[ GROUP BY GroupColumn1 [, GroupColumn2 ... ] ]
[ HAVING lGroupFilter ]
[ UNION [ ALL | DISTINCT ] SELECT ... ]
[ ORDER BY OrderCriteria1 [ ASC | DESC ]
[, OrderCriteria2 [ ASC | DESC ] ... ] ]
[INTO CURSOR CursorName [ NOFILTER ]
| INTO TABLE | DBF TableName
| INTO ARRAY ArrayName
| TO FILE FileName [ ADDITIVE ]
| TO PRINTER [ PROMPT ]
| TO SCREEN ]
[ PREFERENCE PreferenceName ]
[ NOCONSOLE ]
[ PLAIN ]
[ NOWAIT ]
In 6
A+
jml