SELECT InvMovements.StockCode AS stockcode, InvMovements.TrnType AS TranType, InvMaster.ProductClass, InvMovements.TrnQty
FROM InvMovements INNER JOIN
InvMaster ON InvMovements.StockCode = InvMaster.StockCode
GROUP BY InvMovements.StockCode, InvMovements.TrnType, InvMaster.ProductClass, InvMovements.TrnQty, InvMovements.EntryDate
HAVING (InvMovements.TrnType = 'R') AND (InvMaster.ProductClass IN ('TM', 'PM', 'PDM', 'PRM')) AND (InvMovements.EntryDate <= CONVERT(DATETIME,
'2010-05-31 00:00:00', 102)) AND (InvMovements.EntryDate >= CONVERT(DATETIME, '2010-05-01 00:00:00', 102))
ORDER BY InvMovements.StockCode |