Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One Works, One Doesn't
Message
 
To
27/06/2006 08:34:54
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Miscellaneous
Thread ID:
01131819
Message ID:
01131968
Views:
17
TEXT TO lcSelect NOSHOW TEXTMERGE PRETEXT 15
     SELECT * 
            FROM Table1 a
            LEFT JOIN (SELECT * FROM Table2 WHERE incilog.timestamp IN 
                                                   (SELECT TOP 5 timestamp FROM Table2 aInc
                                                          WHERE aInc.unitcode = Table2.unitcode AND
                                                                aInc.unittype= Table2.unittype
                                                          ORDER BY timestamp DESC)) b
           ON  LTRIM(RTRIM(a.unitcode)) = LTRIM(RTRIM(b.unitcode))
           AND LTRIM(RTRIM(a.unittype)) = LTRIM(RTRIM(b.usertyped))
     WHERE a.inactive = 'TRUE' and EXISTS ( SELECT * FROM Table1 WHERE inactive = 'TRUE' )
     ORDER BY a.unitcode, a.unittype, b.timestamp DESC
I am sure there are better ways, but I can't remeber them right now.
I'll try to play with new ranking functions to see what I could do and post my suggestion here.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform