-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix how to handle missing inventory position data for the first day o…
…f the month
- Loading branch information
1 parent
fbd726c
commit 6b7d084
Showing
3 changed files
with
94 additions
and
48 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
.../estoque/report/int_estoque__report_controlados__primeira_posicao_por_estabelecimento.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- Gera a maior data com dados da posição de estoque até o primeiro dia do mês atual | ||
|
||
with | ||
|
||
primeiro_dia_mes as (select date_trunc(current_date('America/Sao_Paulo'), month) as data), | ||
|
||
posicao as ( | ||
select * from {{ ref("fct_estoque_posicao") }} where sistema_origem = 'vitacare' | ||
), | ||
|
||
primeira_posicao_por_estabelecimento as ( | ||
select id_cnes, max(data_particao) as data_particao | ||
from posicao | ||
where data_particao <= (select data from primeiro_dia_mes) | ||
group by id_cnes | ||
) | ||
|
||
select * | ||
from primeira_posicao_por_estabelecimento |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters