Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One Works, One Doesn't
Message
 
To
27/06/2006 12:26:24
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:
01132092
Views:
24
Here an example with new RANK() function:
TEXT TO lcSelect NOSHOW TEXTMERGE PRETEXT 15
     SELECT *
            FROM Table1 a
            LEFT JOIN (SELECT *, RANK() OVER (PARTITION BY unitcode, usertyped ORDER BY TimeStamp DESC) AS Test
                             FROM Table2) b
            ON  LTRIM(RTRIM(a.unitcode)) = LTRIM(RTRIM(b.unitcode))  AND
                LTRIM(RTRIM(a.unittype)) = LTRIM(RTRIM(b.usertyped)) AND
                b.Test < 6
      WHERE a.inactive = 'TRUE' -- and EXISTS ( SELECT * FROM Table1 WHERE inactive = 'TRUE' ) this is extra, if there are
                                -- no records with inactive = 'TRUE' this query didn't returns any records.
      ORDER BY a.unitcode, a.unittype, b.timestamp DESC
ENDTEXT
>Thanks Borislav, I'll play around with it today if I can...
>
>
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform