Test_ID : SELECT im.`Investigation_Id`,im.`TestCode`,im.`Name`,sm.name departmentname , IFNULL(id.`ID`,0) SavedID, IFNULL(Sun,'0')Sun,IFNULL(Mon,'0')Mon,IFNULL(Tue,'0')Tue,IFNULL(Wed,'0')Wed,IFNULL(Thu,'0')Thu,IFNULL(Fri,'0')Fri,IFNULL(Sat,'0')Sat, IFNULL(id.CentreID,'0')CentreID,IFNULL(id.PanelID,'0')PanelID,IFNULL(id.IsUrgent,'0')IsUrgent,IFNULL(id.woringhours,'0')woringhours, ifnull(id.IsCutOff,1)IsCutOff,IFNULL(id.`CutOffTime`,'06:30pm')CutOffTime,IF(IFNULL(id.`dtEntry`,'')='','',DATE_FORMAT(id.`dtEntry`,'%d-%b-%Y %h:%i %p'))SavedDate, IFNULL(id.UserName,'')SavedBy,ExcludeHoliday FROM investigation_master im INNER JOIN f_itemmaster imm ON im.investigation_id=imm.`Type_ID` AND imm.`IsActive`=1 and imm.testcode like '%J-219%' INNER JOIN `f_subcategorymaster` sm ON sm.`SubCategoryID`=imm.`SubCategoryID` AND sm.`Active`=1 and sm.CategoryID='LSHHI3' AND sm.`SubcategoryID`=42 LEFT JOIN `investiagtion_delivery` id ON id.`Investigation_ID`=im.`Investigation_Id` and id.CentreID=3 ORDER BY im.name