Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with SQL Syntax
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00630077
Message ID:
00630106
Views:
22
Duh! You're right. I'm used to using it in subqueries. Back to sleep for me!!

>In VFP TOP clause requires Order BY that determines what columns are taken in account by Top clause. It wouldn't help in this case because it'll return 1 records per query not per group.
>
>>Try Select Top 1 Referral.* instead of your Select Referral.*. This *should* return the earliest (I'm not 100% on whether Top 1 is selected before or after the Order clause).
>>
>>>Hi
>>>
>>>I need confirmation on this, can anyone advise?
>>>
>>>There may be cases in the Referral Table where there may be 2> entries for the same Date (Re_Date) for a Client (Cl_Ref). I want this select to pick up the earliest time'd (Re_Time) Referral if there is more than 1 record for the same Date.
>>>
>>>Hope the above is clear!! Here is my code
>>>
>>>
*Obtain contacts
>>>SELECT Referral.*;
>>>  FROM Referral;
>>> INNER JOIN Client;
>>>    ON Referral.Cl_Ref = Client.Cl_Ref;
>>> WHERE BETWEEN(DTOS(Re_Date), DTOS(gdStartDate), DTOS(gdEndDate));
>>>   AND Re_Message = "R";
>>>   AND Re_Error <> "Y";
>>>   AND Re_Nfa <> "Y";
>>> ORDER BY Re_Time;
>>> GROUP BY Referral.Cl_Ref, Re_Date
>>>
>>>
>>>
>>>Will the above Select do this for me?
>>>
>>>Thanks
>>>Kev
Nigel B Coates
NBC Software Services
Dublin, Ireland.
eMail: Nigel.Coates@NBCSoftware.com
Previous
Reply
Map
View

Click here to load this message in the networking platform