私のSQL文は次のようになります。
SELECT fe.AdmSiteID,A.SiteDescription,
'' AS SNAP, '' AS TANF, '' AS Foster, '' AS FDPIR, '' AS Homeless, '' AS Migrant, '' AS Runaway,
'' AS HeadStart, '' AS EvenStart, '' AS DirectCertified, '' AS NoApplication, '' AS FreeIncome, '' AS ReducedIncome,
'' AS RefusedBenefits,'' AS DeniedIncome, '' AS DeniedVerification, '' AS DeniedNotValid, '' AS TempFreeGrace, '' AS TempReducedGrace,
'' AS DeniedInactive, '' AS DNQ, '' AS ExpiredGrace
FROM FarEligibilityEnrollmentCounts fe
inner join AdmSites A on fe.AdmSiteID = A.AdmSiteID
GROUP BY fe.AdmSiteID,A.SiteDescription
union
select fe.AdmSiteID,A.SiteDescription,sum(PatronCount) as SNAP, '' AS TANF, '' AS Foster, '' AS FDPIR, '' AS Homeless, '' AS Migrant, '' AS Runaway,
'' AS HeadStart, '' AS EvenStart, '' AS DirectCertified, '' AS NoApplication, '' AS FreeIncome, '' AS ReducedIncome,
'' AS RefusedBenefits,'' AS DeniedIncome, '' AS DeniedVerification, '' AS DeniedNotValid, '' AS TempFreeGrace, '' AS TempReducedGrace,
'' AS DeniedInactive, '' AS DNQ, '' AS ExpiredGrace
from FarEligibilityEnrollmentCounts fe
inner join AdmSites A on fe.AdmSiteID = A.AdmSiteID
where fe.FarStudentCaseID = '4FA4AED1-75C9-4CB4-9FF2-102C2D964CC1'
Group BY fe.AdmSiteID,A.SiteDescription
union
select fe.AdmSiteID,A.SiteDescription,'' as SNAP, sum(PatronCount) AS TANF, '' AS Foster, '' AS FDPIR, '' AS Homeless, '' AS Migrant, '' AS Runaway,
'' AS HeadStart, '' AS EvenStart, '' AS DirectCertified, '' AS NoApplication, '' AS FreeIncome, '' AS ReducedIncome,
'' AS RefusedBenefits,'' AS DeniedIncome, '' AS DeniedVerification, '' AS DeniedNotValid, '' AS TempFreeGrace, '' AS TempReducedGrace,
'' AS DeniedInactive, '' AS DNQ, '' AS ExpiredGrace
from FarEligibilityEnrollmentCounts fe
inner join AdmSites A on fe.AdmSiteID = A.AdmSiteID
where fe.FarStudentCaseID = 'B348D33C-5C32-4CFE-B508-1E0CE2A9D428'
Group BY fe.AdmSiteID,A.SiteDescription
クエリは、次のようなデータを返します。
AE1EF8E3-A093-410D-A02A-2B6DB334C758 Dowell Middle School 0 0
0359AF48-882F-4D54-B39D-341B17D64403 Evans Middle School 0 0
0359AF48-882F-4D54-B39D-341B17D64403 Evans Middle School 0 1595
0359AF48-882F-4D54-B39D-341B17D64403 Evans Middle School 1045 0
最終結果が次のようになるように、3 つの Evans Middle School 列をマージしようとしています。
AE1EF8E3-A093-410D-A02A-2B6DB334C758 Dowell Middle School 0 0
0359AF48-882F-4D54-B39D-341B17D64403 Evans Middle School 1045 1595
これを行う方法はありますか?