Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SPT Syntax
Message
 
 
To
01/09/2010 20:03:12
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01479698
Message ID:
01479706
Views:
46
>Don't know what I would do without UT's help.
>
>I have a table with part number, status, datestamp fields. There can be several records of each part number.
>
>I need to know how many records have a ststus of 2 by part number with highest date stamp. I see the need to group by part number in date stamp order, take the latest date and see if the status is 2 and get a total count of these.

Try
select count(distinct PartNo) from Parts P where Status = 2 and PkField = (select top 1 PKField from 
Parts P1 where P1.PartNo = P.PartNo order by DateStamp DESC)
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