Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Selecting data where field = max(field)
Message
From
03/11/2011 12:14:27
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01527898
Message ID:
01527960
Views:
50
>>PLEASE NOTE --- VFP8
>>
>>I need to get the records for a department based on the last time it was printed. I've got
>>SELECT dept,MAX(printtime) as pt ;
>>   FROM prn_status ;
>>   WHERE wono = ww ;
>>   GROUP BY dept ;
>>   INTO CURSOR curTemp
>>
>>SELECT p1.* ;
>>  FROM prn_status p1 ; 
>>    JOIN curTemp ct  ON p1.dept = ct.dept AND p1.printtime = ct.pt ;
>>  WHERE p1.wono = ww;
>>  INTO CURSOR crsData
>>
>>Is there a simple way to combine this into one query?
>>
>>Thanks to all..............Rich
>
>select p1.* from prn_Status p1
>where PrintTime = (select max(PrintTime) from prn_Status p where p.dept = p1.dept)
Thanks Naomi. I appreciate the help.

It turns out that it's MUCH faster to split it into two queries so I'm going to keep the original code.

Again, thanks

.......Rich
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform