Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Subquery Troubles
Message
De
21/11/2014 14:43:10
 
 
À
20/11/2014 13:14:02
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01611202
Message ID:
01611306
Vues:
71
Ok I've taken everyone's suggestions and the following is what I have come up with. I'm almost there... This returns all of the fields I need but too many records. It's essentially returning the last receipt for every combination of Item+vendno in the ICSUPL01.DBF. Which makes sense being that both of these fields are in the Group By clause. I only wanted to Group By item but VFP is requiring vendno to be included also. I can;t omit vendno from the select because it's needed for the join with APVEND01.DBF. Any suggestions?
SELECT I.item,;
	   I.itmdesc,;
	   I.plinid,;
	   I.lookup,;
	   I.stkumid,;
	   I.altitm1,;
	   I.avgcost,;
	   I.lstcost,;
	   I.ilsale,;
	   I.itmclss,;
	   I.comcode,;
	   L.loctid,;
	   L.lonhand,;
	   L.lsoaloc,;
	   L.lvprtno,;
	   L.lsupplr,;
	   L.lonordr,;
	   L.ORDERPT,;
       L.YTDSLQT,;
       S.lrecdte,;
       S.vendno,;
       V.company,;
	   CAST(0 AS N(15,5)) AS MONTHSLQT;
	FROM icitem01 I;
		LEFT JOIN iciloc01 L;
		ON I.item = L.item;
		INNER JOIN;
		(SELECT vendno, item , MAX(LRECDTE) as LRECDTE FROM icsupl01 GROUP BY vendno,item) S;
         ON I.item = S.item; 
         INNER JOIN apvend01 v; 
         ON S.vendno = V.vendno;
	WHERE I.stkcode = 'Y' AND len(alltrim(I.item)) > 0;
	ORDER BY I.item, L.loctid
TIA
Jeff
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform