diff --git a/models/br_ms_sia/br_ms_sia__producao_ambulatorial.sql b/models/br_ms_sia/br_ms_sia__producao_ambulatorial.sql index 16b36e9b..8e9bc4d2 100644 --- a/models/br_ms_sia/br_ms_sia__producao_ambulatorial.sql +++ b/models/br_ms_sia/br_ms_sia__producao_ambulatorial.sql @@ -28,7 +28,7 @@ with on producao_ambulatorial.pa_ufmun = mun.id_municipio_6 ), - producao_ambulatorial as ( + sia as ( select safe_cast(ano as int64) ano, @@ -223,12 +223,12 @@ with ) select * -from producao_ambulatorial +from sia {% if is_incremental() %} left join {{ this }} as materialized - on sia_add_municipios.ano = materialized.ano - and sia_add_municipios.mes = materialized.mes + on sia.ano = materialized.ano + and sia.mes = materialized.mes where materialized.ano is null and materialized.mes is null {% endif %}