SELECT ItemCode, CASEWHEN XnType='PUR'THEN XnQty ELSE0ENDAS Purchase,
CASEWHEN XnType='SLS'THEN XnQty ELSE0ENDAS Sale
FROM rf
GROUPBY ItemCode
Something like that
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller The only thing normal about database guys is their tables.