select eo.EducationOrganizationId,eo.NameOfInstitution,d.CodeValue as CodeType, eic.IdentificationCode ,case when esc.EducationServiceCenterId is not null then 'Y' else 'N' end as EdSvcCtr ,case when lea.LocalEducationAgencyId is not null then 'Y' else 'N' end as LEA ,case when sch.SchoolId is not null then 'Y' else 'N' end as School from edfi.EducationOrganizationIdentificationCode eic left join edfi.EducationOrganization eo on eo.EducationOrganizationId=eic.EducationOrganizationId left join edfi.Descriptor d on d.DescriptorId=eic.EducationOrganizationIdentificationSystemDescriptorId left join edfi.EducationServiceCenter esc on esc.EducationServiceCenterId=eo.EducationOrganizationId left join edfi.School sch on sch.SchoolId=eo.EducationOrganizationId left join edfi.LocalEducationAgency lea on lea.LocalEducationAgencyId=eo.EducationOrganizationId order by eo.NameOfInstitution,d.CodeValue