How to get balance of of remaining medicine batch wise
Basically you cannot GROUP BY the type, because you want the  SUM of both types
SELECT itemcode, batchno, eXpirydate,
    SUM(CASE
         WHEN type= 1 THEN qty
         WHEN type= 2 THEN qty*-1
    END) AS balance 
FROM strans   
GROUP BY itemcode, batchno, EXpirydate