Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to retrieve latest production date for each repair o
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01228970
Message ID:
01229008
Views:
26
>Looking at this part
>
>
>lu_key IN ;
> (SELECT CTOBIN(RIGHT(MAX(DTOS(item_date )+BINTOC(lu_key )),4)) ;
>
>I'm trying to figure out in which order the processing takes place so I can understand the logic behind it. The 2 fields are concatenated, then you find the max aggregate, retrieve the last 4 char and convert to binary which will compare to the "lu_key IN" statement.
>
>Is that correct? My main question is: How can you do a comparison on 2 separate fields that are combined? I never knew you could do that.
>
>Thanks,
>
>Marcel

After all the conversions you get back the ID field for the max date. You also get the max ID if you have 2 same dates in your table, so you always retrieve just one record per max date. In the second link I provided there was another SQL, which would retrieve all records with the same max date. So, you may choose which SQL suits your needs best.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform