select p.projectname, c.customername, w.welderid, wt.weldtypename, wtt.testtypename, (select count(ws.statusname) from weldStatus ws where statusName like ('Reweld')) 'Number of Rewelds', wp.procedurename, smdc.name, weld.weldid, weld.welderid, tr.result, tcod.Data, (select Count(wtt.testtypename) from WeldTestType wtt where wtt.testTypeName like ('X-Ray')) as 'Number of Welds X-Rayed', (select count(weld.welderid)/(select Count(wal.weldStatusId) from weldActivityLog wal, weld where weld.weldId = wal.weldId and wal.weldstatusId = 5) from weld, weldActivityLog wal where weld.weldId = wal.weldId) 'Repair Percent Per Welder' from project p,customer c,welder w, employee e, projectemployee pe, weldtype wt, weld,weldtesttype wtt, weldtest wtest, weldstatus ws, weldactivitylog wal,weldprocedure wp,specificationmatrixdatacolumn smdc, specificationMatrix sm, projectspecificationMatrix psm, testresult tr, testColumnObjectData tcod, specification spec where p.customerid = c.customerid and p.projectid = pe.projectid and pe.employeeid = e.employeeid and e.employeeid = w.employeeid and wt.weldtypeid = weld.weldtypeid and weld.welderid = w.welderid and wtt.weldtesttypeid = wtest.weldtesttypeid and wtest.weldid = weld.weldid and ws.weldstatusid = wal.weldstatusid and wal.weldid = weld.weldid and wp.weldprocedureid = weld.weldprocedureid and smdc.specificationmatrixid = sm.specificationmatrixid and sm.specificationmatrixid = psm.specificationmatrixid and psm.projectId = p.projectId and tr.testresultid = wtest.testresultid and tcod.SpecificationId = Spec.SpecificationId and spec.WeldProcedureId = Wp.WeldProcedureId and c.customerName = @CustomerName and p.projectName = @projectName