Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can this be done in one SQL Select?
Message
From
08/02/2005 19:47:04
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00984864
Message ID:
00984989
Views:
19
>I need help in selecting records from the following table (simplified):
>
>CUST_ID
>ORD_DATE
>ORD_TIME
>
>For a given date (ORD_DATE), I need to select one order record per customer (CUST_ID) based on the time of order (ORD_TIME). For example, the Order Time should be the latest of the day.
>
>I would appreciate any suggestions.
>
>Thank you.
dGivenDate=DATE()
SELECT * INTO CURSOR Results;
  FROM theTable T ;
  WHERE ORD_DATE=m.dGivenDate;
    AND T.ORD_TIME =(SELECT MAX(ORD_TIME) FROM theTable WHERE ORD_DATE=T.ORD_DATE AND CUST_ID=T.CUST_ID)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform