Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selecting MAX Date
Message
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 SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Divers
Thread ID:
01531005
Message ID:
01531006
Vues:
43
>I wrote a SQL statement that appeared to be okay, but it has an error:
>
>"SQL: column 'EFF_DATE' is not found".
>
>What did I do wrong? I am trying to not have dupe records. The only way to do that is to get the Maximum Effective Date.
>
>SELECT DISTINCT cv.GrpID, cv.GrpNum, in.Emp_ID, in.LastName, in.FirstName, in.SS_Number, ;
>		cv.Eff_Date;
>	FROM GRPEXTIN in ;
>	JOIN ;
>		(SELECT GrpID, GrpNum, MAX(Eff_Date) AS MaxEffDate FROM GRPEXTCV GROUP BY GrpID, GrpNum) cv ;
>		ON in.GrpID+in.GrpNum=cv.GrpID+cv.GrpNum  ;
>	WHERE cv.Hist ='99' AND ;
>		(INLIST(cv.GrpID, "ACS") AND ;
>		INLIST(cv.Status, 'A' ,'B') AND ;
>		cv.Renewal<>'H') ;
>	ORDER BY cv.GrpID, cv.GrpNum ;
>	INTO CURSOR tmpResults
>
You named your date as MaxEffDate, so this is the name you should use in your query. Also, I suggest to use join as
In1.GrpID = cv.GrpID and In1.GrpNum = cv.GrpNum

and use something like In1 instead of In for first table alias. Finally, instead of INLIST I suggest using IN to make the code more SQL like.
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