SELECT  'I', ItemID,  (SELECT Item_Name FROM $master_db.Sales_Inventory_Items WHERE Item_Id = ItemID) as 'Item', SUM(Dr_Qty) as 'Qty' , SUM(Dr_Qty) /  cast(DATEDIFF(str_to_date('$toDateTime','%Y-%m-%d %H:%i:%s'),str_to_date('$fromDateTime','%Y-%m-%d %H:%i:%s') ) as Int) as 'Production Rate'  FROM $trans_db.Transaction_Item_Helper WHERE VoucherDate >=str_to_date('$fromDateTime','%Y-%m-%d %H:%i:%s') AND VoucherDate <=str_to_date('$toDateTime','%Y-%m-%d %H:%i:%s') AND VoucherType = 'Work Order' GROUP BY ItemID ORDER BY Item