SELECT 'I' as Ind, trans.ItemID, (SELECT ITEM_NAME FROM $master_db.Sales_Inventory_Items WHERE ITEM_ID = TRANS.ITEMID) AS ITEM,CR_QTY as Cr,DR_QTY as Dr, COALESCE(SUM(CR_QTY),0) AS CREDIT, COALESCE(SUM(DR_QTY),0) AS DEBIT  FROM $trans_db.TRANSACTION_ITEM_HELPER TRANS WHERE FROM_LEDGER = '$f1' OR TO_LEDGER = '$f1' AND TRANS.VOUCHERDATE >= str_to_date('$fromDateTime','%Y-%m-%d') AND TRANS.VOUCHERDATE <= str_to_date('$toDateTime','%Y-%m-%d') GROUP BY ITEMID