-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCom_Count Alt Precos.sql
45 lines (34 loc) · 1.48 KB
/
Com_Count Alt Precos.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
39
40
41
42
43
44
SELECT NROEMPRESA, COUNT(SEQLOGPRECO) QTD_ALTERACOES
FROM CONSINCO.MAD_PRODLOGPRECO A
WHERE --SEQPRODUTO = 5500
A.DTAHORALTERACAO BETWEEN DATE '2022-01-01' AND DATE '2022-03-31'
AND QTDEMBALAGEM = 1
AND NROEMPRESA NOT IN (31,41)
GROUP BY NROEMPRESA
UNION ALL
SELECT NROEMPRESA, COUNT(SEQLOGPRECO) QTD_ALTERACOES
FROM CONSINCO.MAD_PRODLOGPRECO A
WHERE --SEQPRODUTO = 5500
A.DTAHORALTERACAO BETWEEN DATE '2022-01-01' AND DATE '2022-03-31'
--AND QTDEMBALAGEM = 1
AND NROEMPRESA IN (31,41)
GROUP BY NROEMPRESA
ORDER BY 1
----------------------------------------------------
-- ALterações em oferta
SELECT NROEMPRESA,(SELECT COUNT(B.SEQLOGPRECO)
FROM CONSINCO.MAD_PRODLOGPRECO B
WHERE B.DTAHORALTERACAO BETWEEN DATE '2022-11-01' AND DATE '2022-11-30'
AND B.QTDEMBALAGEM = 1
AND B.NROEMPRESA = A.NROEMPRESA -- NOT IN (31,41)
AND B.SEQPROMOCAO IS NOT NULL
AND B.NROSEGMENTO = 2 -- Alterações apenas no segmento Nagumo SP
GROUP BY NROEMPRESA) QTD_ALTERACOES_NOV,
COUNT(SEQLOGPRECO) QTD_ALTERACOES_DEZ
FROM CONSINCO.MAD_PRODLOGPRECO A
WHERE A.DTAHORALTERACAO BETWEEN DATE '2022-12-01' AND DATE '2022-12-22'
AND QTDEMBALAGEM = 1
AND NROEMPRESA = 51 -- NOT IN (31,41)
AND SEQPROMOCAO IS NOT NULL
AND A.NROSEGMENTO = 2 -- Alterações apenas no segmento Nagumo SP
GROUP BY NROEMPRESA