-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCom_Count Prod Promo.sql
38 lines (24 loc) · 1.62 KB
/
Com_Count Prod Promo.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
ALTER SESSION SET CURRENT_SCHEMA = CONSINCO;
SELECT 'TOTAL' EMP, 'Mes: '||06||' - Ano: 2024' Periodo,
ROUND(AVG(NAGF_BUSCAQTDITENSPROMOC_SM(06,2024,EMP.NROEMPRESA,1))) PRIM_SEMANA,
ROUND(AVG(NAGF_BUSCAQTDITENSPROMOC_SM(06,2024,EMP.NROEMPRESA,2))) SEG_SEMANA,
ROUND(AVG(NAGF_BUSCAQTDITENSPROMOC_SM(06,2024,EMP.NROEMPRESA,3))) TER_SEMANA,
ROUND(AVG(NAGF_BUSCAQTDITENSPROMOC_SM(06,2024,EMP.NROEMPRESA,4))) QUAR_SEMANA
FROM MAX_EMPRESA EMP WHERE NROEMPRESA < 100
UNION ALL
SELECT 'TOTAL' EMP, 'Mes: '||07||' - Ano: 2024' Periodo,
ROUND(AVG(NAGF_BUSCAQTDITENSPROMOC_SM(07,2024,EMP.NROEMPRESA,1))) PRIM_SEMANA,
ROUND(AVG(NAGF_BUSCAQTDITENSPROMOC_SM(07,2024,EMP.NROEMPRESA,2))) SEG_SEMANA,
ROUND(AVG(NAGF_BUSCAQTDITENSPROMOC_SM(07,2024,EMP.NROEMPRESA,3))) TER_SEMANA,
ROUND(AVG(NAGF_BUSCAQTDITENSPROMOC_SM(07,2024,EMP.NROEMPRESA,4))) QUAR_SEMANA
FROM MAX_EMPRESA EMP WHERE NROEMPRESA < 100
-- Abaixo é por Loja
UNION ALL
SELECT NULL, NULL, NULL, NULL, NULL, NULL FROM DUAL
UNION ALL
SELECT TO_CHAR(NROEMPRESA), 'Mes: '||07||' - Ano: 2024' Periodo,
NAGF_BUSCAQTDITENSPROMOC_SM(07,2024,EMP.NROEMPRESA,1) PRIM_SEMANA,
NAGF_BUSCAQTDITENSPROMOC_SM(07,2024,EMP.NROEMPRESA,2) SEG_SEMANA,
NAGF_BUSCAQTDITENSPROMOC_SM(07,2024,EMP.NROEMPRESA,3) TER_SEMANA,
NAGF_BUSCAQTDITENSPROMOC_SM(07,2024,EMP.NROEMPRESA,4) QUAR_SEMANA
FROM MAX_EMPRESA EMP WHERE NROEMPRESA < 100