CREATE PROCEDURE `spGetBatchList` ( IN `P_TeacherId` INTEGER , IN `P_InstituteId` INTEGER ) BEGIN SELECT DISTINCTROW `B` . `Id` AS `BatchId` , `B` . `Title` AS `BatchName` , CAST ( `FS` . `DateOfFeeCollection` AS CHARACTER ) AS `CreatedDateTime` , CAST ( `ifnull` ( `FS` . `DateOfFeeCollection` , ? ) AS CHARACTER ) AS `DueDate` , `ifnull` ( `FS` . `DefaultFeeAmount` , ? ) AS `Amount` , ( SELECT COUNT ( `BatchId` ) FROM `tassignbatch` WHERE `StatusId` = ? AND `BatchId` = `B` . `Id` ) AS `StudentCount` FROM `tteacher` `t` INNER JOIN `tBatch` `B` ON `B` . `TeacherId` = `t` . `Id` LEFT JOIN `tassignbatch` `AB` ON `AB` . `BatchId` = `B` . `Id` INNER JOIN `tfeesetup` `FS` ON `FS` . `TeacherId` = `t` . `Id` AND `FS` . `BatchId` = `B` . `Id` WHERE `t` . `Id` = `P_TeacherId` AND `t` . `Instituteid` = `P_InstituteId` ; SELECT DISTINCTROW `B` . `Id` AS `BatchId` , `B` . `Title` AS `BatchName` , ( SELECT COUNT ( `BatchId` ) FROM `tassignbatch` WHERE `StatusId` = ? AND `BatchId` = `B` . `Id` ) AS `StudentCount` FROM `tteacher` `t` INNER JOIN `tBatch` `B` ON `B` . `TeacherId` = `t` . `Id` LEFT JOIN `tassignbatch` `AB` ON 