Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning Greatest Date Stamp Using SPT
Message
 
 
À
30/01/2009 06:30:29
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
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01378388
Message ID:
01378391
Vues:
7
>The following actually returns two records. One for vendor code G7820 and one for SEE SCAN. I need the one with the last datstmpi value.
>
>
>testString = "Select recseq, CASE WHEN faistatus = 1 THEN 'Accepted' WHEN faistatus = 2" +;
>" THEN 'Rejected' ELSE 'SEE ORIGINAL FAI' END As fais, inspectord, dwgrev, datstmpi From webprddt6.drawmfai" +;
>" mt1 JOIN ( SELECT webprddt6.drawmfai.partno, MAX(webprddt6.drawmfai.datstmpi) AS MaxDate FROM" +;
>" webprddt6.drawmfai Where toolinspr = 0 And conformir = 0 And DATE(datstmpin) is Not NULL" +;
>" GROUP BY webprddt6.drawmfai.partno, webprddt6.drawmfai.vendorcode ) mt3 ON mt3.partno = mt1.partno" +;
>" AND mt3.MaxDate = mt1.datstmpi Where mt1.partno in('840950-15-999 F','840950-15 F','840950-15-999 '" +;
>",'840950-15-9','840950-15-','840950-15','840950-1') And (Left(mt1.vendorcode,5) = 'G7820' Or" +;
>" (mt1.dwgtitle = 'See original FAI' And Left(mt1.vendorcode,8) = 'SEE SCAN')) And toolinspr = 0 And conformir = 0"
>
Which backend? For SQL Server 2005 and up
select * from (Select recseq, row_number() over (ORDER BY DatStmpi DESC) RowNumber, CASE WHEN faistatus = 1 THEN 'Accepted' WHEN faistatus = 2" +;
>" THEN 'Rejected' ELSE 'SEE ORIGINAL FAI' END As fais, inspectord, dwgrev, datstmpi From webprddt6.drawmfai" +;
>" mt1 JOIN ( SELECT webprddt6.drawmfai.partno, MAX(webprddt6.drawmfai.datstmpi) AS MaxDate FROM" +;
>" webprddt6.drawmfai Where toolinspr = 0 And conformir = 0 And DATE(datstmpin) is Not NULL" +;
>" GROUP BY webprddt6.drawmfai.partno, webprddt6.drawmfai.vendorcode ) mt3 ON mt3.partno = mt1.partno" +;
>" AND mt3.MaxDate = mt1.datstmpi Where mt1.partno in('840950-15-999 F','840950-15 F','840950-15-999 '" +;
>",'840950-15-9','840950-15-','840950-15','840950-1') And (Left(mt1.vendorcode,5) = 'G7820' Or" +;
" (mt1.dwgtitle = 'See original FAI' And Left(mt1.vendorcode,8) = 'SEE SCAN')) And toolinspr = 0 And conformir = 0) myInfo where RowNumber
=1
I think actually in your case it should be simple

select TOP 1 original select ORDER BY DatStampI DESC
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform