Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SPT to Get a Set of Single Records
Message
 
 
To
29/07/2008 07:12:29
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
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01334815
Message ID:
01334817
Views:
7
This message has been marked as the solution to the initial question of the thread.
>I have a table with records in which the only difference in the record data might be the recseq no.(This is a many type table). What I need to do is have a SPT statement that gets three fields. The recseq, partnumber, and description fields. The twist is I only want distinct partnumber values. The recseq could be the max for the partnumber maybe.
>

Try (will work in VFP9 or with VFP9 OLE DB provider only)
SELECT mt.recseq, mt.partnumber, mt.description FROM mytable mt
  JOIN (SELECT MAX(recseq) AS maxrecseq, partnumber FROM mytable GROUP BY partnumber) mrs
  ON mrs.maxrecseq = mt.recseq AND mrs.partnumber  = mt.partnumber 
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform