The following query bring the correct value for totalqty. however it leaves or misses counting the qty for some items, why?
SELECT
PRODID, ITEMDES, QTY, SUM(QTY) over (partition by prodId) as totalqty, StockCode,shipName, shipCompany, shipAddress1, shipAddress2, shipAddress3,shipPostCode,shipcity,shipCountry,shipCounty,customerMessage
FROM orderedItems oi
left join orders o on oi.order_id = o.order_id
WHERE prodId = prodId
AND o.status = 'transaction authorised'
AND o.delTime = '#FORM.delDateselect#'
Group by PRODID,ITEMDES,QTY, StockCode,shipName, shipCompany, shipAddress1, shipAddress2, shipAddress3,shipPostCode,shipcity,shipCountry,shipCounty,customerMessage
ORDER BY PRODID
Your
whereclause makes theleft outer joinbehave like aninner join. Change it like this:The reason is that if there is no matching order in
orderso.statuswill beNULLand thus not equal to'transaction authorised'.Furthermore, you don’t need the group by. You already have the analytical function that does the
SUMfor you.