Okay, here's a SQL SELECT that I lovingly handcrafted in the command window. It runs like greased lightning. A huge improvement over the one I started with.
What's just totally disgustipating is when I try to save it as a VIEW (which I REALLY need), VFP coughs and moans something about it being too complex! Silly.
SELECT syProjects.iSyPj_PK, syProjects.cDesc AS ProjectName, syProjects.crefno AS ReferenceNum, ;
IIF(Syprojects.iactive=0,"N","Y") AS active, syProgram.cName AS ProgramName, ;
(SELECT NVL(SUM(ROUND(((tmTimeSheets.iEndTime - tmTimeSheets.iStartTime)/60)*tmTimeSheets.nhrwage,2)),0.00) ;
FROM tmTimeSheets ;
WHERE syProjects.iSyPj_PK = tmTimeSheets.iSyPj_FK) AS TimeCost, ;
(SELECT NVL(SUM(ROUND((tmMileage.nEndMiles - tmMileage.nStartMiles) * tmMileage.nMileRate,2)),0.00) ;
FROM tmMileage ;
WHERE syProjects.iSyPj_PK = tmMileage.iSyPj_FK) AS MileCost, ;
(SELECT NVL(SUM(crCashDist.nAmt),0.00) ;
FROM crCashDist ;
WHERE syProjects.iSyPj_PK = crCashDist.iSyPj_FK) AS CashReceipts ;
FROM syProjects ;
LEFT OUTER JOIN syProgram ON Syprojects.isypg_fk = Syprogram.isypg_pk ;
ORDER BY ProjectName

























Recent Comments