Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SPT Syntax help
Message
 
 
À
24/08/2010 17:11:51
Steven Dyke
Safran Seats USA
Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01478231
Message ID:
01478237
Vues:
39
>Remote Database is DB2.
>
>I have table a which is a list of part numbers.
>
>Table b is a list of inspections performed on these part numbers. This table can have multiple records of each part number. Each record has a datetime stamp field and a status.
>
>I need a list of part numbers from table a where the last record(greatest datetime stamp) is status 2(rejected).
>
>
>
>Select partno From table a Where partno in (Select partno From table b Where status = 2 Order By datetime stamp Desc Fetch First 1 Rows Only)
>
>
>
>This gives me the first record of the part number group with a status of 2. However, there is a newer record with a status of 1 so this record should not be in result set.
select PartNo from Table a where a.Status = 2 and a.DateTime = (select max(DateTime) from Table b where a.PartNo = b.PartNo) 
Latest date for that PartNo.
If we don't have multiple statuses per PartNo, then
select PartNo from Table a where a.Status = 2 and a.DateTime = (select max(DateTime) from Table b)
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform