내 쿼리는 다음과 같습니다. 그것이 잘 실행되었다고 가정합시다. 여기서 조항의 마지막 부분을 혼동했습니다. 두 개의 다른 테이블에서 글을 쓸 수 있습니까? 어떻게 쓸 수 있습니까? 그 날짜 범위의 Active 직원을 표시하고 싶습니다.쿼리의 Where 절
select d.Division,a.FirstName,
(select count(h.id) from Department h
inner join institution i on d.institution_id = i_Id
----
----
where i.institution_id =d.Id and h. date between @startDate and @endDate) as test
from Division d, inmate a
where d.Active = 1 and a.Active = 1
내가 편집 내 쿼리와 같은 최종 모습이 편집 ..
select d.DivisionName,a.FirstName, (select count(h.id) from InHistory h inner join Institution i on h.Institution_id = i.Id inner join InType it on h.InType_id = it.Id inner join mate a on h.mate_id = a.Id where i.InstitutionRegion_id = d.Id and it.InTypeName like '%Staff%' and h.AdmissionDate between '18/02/2013' and '18/02/2013') as Admission from Division d, mate a where d.Active= 1 and a.Active =1
를 참조 – Patashu
왜 하위 쿼리에서 조인을하고 이러한 조인을 사용하여 외부 쿼리를 수행합니까? – andho
실수가 아니라면 대답은 – c0dem0nkey