데이터, 네트워크 및 소프트웨어라는 세 개의 테이블이 있습니다. 네트워크 및 소프트웨어 테이블에 서비스 티켓이있는 동안 데이터 테이블에는 모든 고객의 이름이 있습니다. 두 표 (네트워크 또는 소프트웨어) 중 하나에서 매월 클라이언트 당 최소 한 개의 티켓이 필요합니다. 매월 데이터 테이블의 각 클라이언트에 대해 두 테이블 (네트워크 및 소프트웨어)의 티켓을 계산하는 쿼리가 필요합니다.두 테이블의 행을 세 번째 테이블에 연결합니다.
욕망 결과 : Final query
나는이 쿼리와 함께 계산하는 방법을 발견하지만 난 두 테이블에서 계산하는 방법을 모르겠어요.
SELECT institucion
,(SELECT count(institucion) FROM network WHERE data.institucion = network.institucion and fecha like '2016-07%')as July
,(SELECT count(institucion) FROM network WHERE data.institucion = network.institucion and fecha like '2016-08%')as August
,(SELECT count(institucion) FROM network WHERE data.institucion = network.institucion and fecha like '2016-09%')as September
,(SELECT count(institucion) FROM network WHERE data.institucion = network.institucion and fecha like '2016-10%')as October
,(SELECT count(institucion) FROM network WHERE data.institucion = network.institucion and fecha like '2016-11%')as November
,(SELECT count(institucion) FROM network WHERE data.institucion = network.institucion and fecha like '2016-12%')as December
,(SELECT count(institucion) FROM network WHERE data.institucion = network.institucion and fecha like '2017-01%')as January
,(SELECT count(institucion) FROM network WHERE data.institucion = network.institucion and fecha like '2017-02%')as February
,(SELECT count(institucion) FROM network WHERE data.institucion = network.institucion and fecha like '2017-03%')as March
,(SELECT count(institucion) FROM network WHERE data.institucion = network.institucion and fecha like '2017-04%')as April
,(SELECT count(institucion) FROM network WHERE data.institucion = network.institucion and fecha like '2017-05%')as May
,(SELECT count(institucion) FROM network WHERE data.institucion = network.institucion and fecha like '2017-06%')as June
FROM data
where data.erate = 'y'
order by institucion