我有下面的三个查询,我想将它们组合成一个查询,所以我得到三列按县列出的结果。我尝试对所有表进行内部连接,但我得到了错误的数据。如何结合这三个查询并按县分组?
select co.Description
from Counties as co
group by co.Description
select [Total DLL Children] = SUM(cd.NumberOfLanguageSpeakers)
from ClassroomDLL as cd
inner join Classrooms as c on cd.Classroom_Id = c.Id
inner join Sites as s on c.Site_Id = s.Id
inner join Profiles as p on s.Profile_Id = p.Id
inner join Counties as co on p.County_Id = co.Id
group by co.Description
select
[Total Children] = (SUM(demo.NumberOfPreschoolers)
+ SUM(demo.NumberOfToddlers) + SUM(demo.NumberOfInfants))
from ClassroomDemographics as demo
inner join Classrooms as c on demo.Classroom_Id = c.Id
inner join Sites as s on c.Site_Id = s.Id
inner join Profiles as p on s.Profile_Id = p.Id
inner join Counties as co on p.County_Id = co.Id
group By co.Description