Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Last transaction of each transaction type
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01508934
Message ID:
01508959
Views:
29
>So far my code is:
>
>
>SELECT type,desc,* FROM wipdata!logfile tl   WHERE  Date  =  (SELECT MAX(date)  FROM logfile WHERE Jobno = tl.Jobno AND Type = tl.Type) into cursor tmptrans
>
>
>So to look up the employees/operators name from another table in SQL I would usually do something like this:
>
>
>SELECT *,CNAME FROM wipdata!logfile,wipdata!operators where OPERATOR=NEMPNO into cursor tmptrans
>
>

Try
SELECT LG.*, OP.cName from LogFile LG INNER JOIN Operators OP on LG.Operators = OP.NEmpno ;
INNER JOIN (select Max(Date) as LastDate, JobNo, Type from LogFile ;
GROUY BY JobNo, Type) X ON LG.JobNo = X.JobNo and LG.Type = X.Type and LG.Date = X.LastDate
I prefer derived table approach to correlated subquery - you may want to test both methods to compare performance.
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