SELECT ExportDestination.Title,ExportStatus.Title_E,COALESCE(Temp.CountRecord,0) AS CountRecord FROM (SELECT Export.NoExportStatus,Export.NoExportDestination,COUNT(*) AS CountRecord FROM Export (NOLOCK) GROUP BY Export.NoExportStatus,Export.NoExportDestination) Temp INNER JOIN ExportDestination ON Temp.NoExportDestination=ExportDestination.Numero RIGHT JOIN ExportStatus ON Temp.NoExportStatus=ExportStatus.NumeroIt gets a result like this:
Title Title_E CountRecord NULL Pending 0 First destination Completed 13209 Second destination Completed 13209 NULL In progress 0 NULL Calculated 0 NULL Retry 0