General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Correction on previous message.
I had a little trouble with the TAB button trying to modify the layout of the select stament. But here it is
SELECT cArtCode, UPPER(cArtGrp) AS cArtgrp, cArtNaam, ;
SUM(iAantal*IIF(factuur.lCredNota,-1,1))AS iTotAant,;
SUM(iAantal*nArtInkPrs*IIF(Factuur.lcrednota,-1,1)) As nTotInk, ;
SUM(iAantal*nArtPrs*IIF(factuur.lCredNota,-1,1)) AS nTotVerk,;
SUM(iAantal*(nartPrs*IIF(facregels.iArttype=1,factuur.nKortPerc1/100,;
factuur.nKortperc2/100) ) )as nKort ;
FROM FacRegels,Factuur ;
WHERE Between(Factuur.dFacDatum,dDatVan,dDatTot) ;
AND YEAR(facregels.dFacdatum)+FacRegels.iFactuurnr = ;
YEAR(Factuur.dFacdatum)+ Factuur.iFactuurnr ;
UNION ;
SELECT cArtCode, UPPER(cArtGrp) AS cArtGrp, cArtNaam, ;
SUM(iAantal*IIF(fac.lCredNota,-1,1)) AS iTotAant, ;
SUM(iAantal*nArtInkPrs*IIF(Fac.lCrednota,-1,1)) As nTotInk, ;
SUM(iAantal*nArtPrs*IIF(fac.lCredNota,-1,1)) AS nTotVerk, ;
SUM(iAantal*(nartPrs*IIF(facrg.iArttype=1,fac.nKortPerc1/100, ;
fac.nKortperc2/100) ) )as nKort ;
FROM FacRg,Fac ;
WHERE Between(Fac.dFacDatum,dDatVan,dDatTot) ;
AND YEAR(facrg.dFacdatum) + Facrg.iFactuurnr = ;
YEAR(Fac.dFacdatum) + Fac.iFactuurnr ;
GROUP BY 1 ;
ORDER BY 2,1 ;
INTO CURSOR crVerk
The problem i have is when there's no record found in the Fac or Factuur tables it returns only one record whith an iAantal (amount) which is incorrect.
Does anybody know this fenomenon or can someone do me an better suggestion for this
Thanks in advance
Eric de Bruin
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only