extracted objects
This commit is contained in:
69
docs/views/V_GRIGLIA.md
Normal file
69
docs/views/V_GRIGLIA.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# V_GRIGLIA
|
||||
|
||||
## Colonne
|
||||
|
||||
| Colonna | Tipo |
|
||||
|---------|------|
|
||||
| ID | NUMBER |
|
||||
| TIPO_RIEPILOGO | VARCHAR2(20) |
|
||||
| RNK | NUMBER |
|
||||
| DES_TIPO | VARCHAR2(1000) |
|
||||
| LUN | VARCHAR2(4000) |
|
||||
| MAR | VARCHAR2(4000) |
|
||||
| MER | VARCHAR2(4000) |
|
||||
| GIO | VARCHAR2(4000) |
|
||||
| VEN_1 | VARCHAR2(4000) |
|
||||
| VEN_2 | VARCHAR2(4000) |
|
||||
| SAB_1 | VARCHAR2(4000) |
|
||||
| SAB_2 | VARCHAR2(4000) |
|
||||
| DOM_1 | VARCHAR2(4000) |
|
||||
| DOM_2 | VARCHAR2(4000) |
|
||||
|
||||
## Definizione
|
||||
|
||||
```sql
|
||||
CREATE OR REPLACE VIEW V_GRIGLIA AS
|
||||
with t as (
|
||||
select to_char(data,'IW') week,
|
||||
-- to_char(data,'d', 'NLS_DATE_LANGUAGE = italian') giorno,
|
||||
to_char(data,'d') giorno,
|
||||
-- to_char(data,'d', 'NLS_DATE_LANGUAGE = italian') * 100000 + E.ID giorno,
|
||||
E.ID ,
|
||||
DENSE_RANK() OVER (PARTITION BY to_char(data,'d', 'NLS_DATE_LANGUAGE = italian') * 100000 ORDER BY e.id) rnk,
|
||||
e.data,e.descrizione,
|
||||
p.cod_articolo,
|
||||
a.descrizione des_art,
|
||||
a.cod_categ,
|
||||
c.descrizione des_categ,
|
||||
c.cod_tipo ,
|
||||
t.descrizione des_tipo,
|
||||
c.tipo_riepilogo
|
||||
from eventi e
|
||||
join eventi_det_prel p on e.id = p.id_evento
|
||||
join articoli a on p.cod_articolo = a.cod_articolo
|
||||
join tb_codici_categ c on a.cod_categ = c.cod_categ
|
||||
join tb_tipi_mat t on c.cod_tipo = t.cod_tipo
|
||||
-- where to_char(data,'IW') = to_char(to_date(:P14_SETTIMANA,'DD-MON-YYYY'),'IW')
|
||||
where to_char(data,'IW') = to_char(to_date('05-MAY-2018','DD-MON-YYYY'),'IW')
|
||||
|
||||
)
|
||||
, t_des as (
|
||||
select ID,rnk,
|
||||
t.tipo_riepilogo,
|
||||
t.DES_TIPO,
|
||||
t.descrizione,
|
||||
case when giorno = 1 then t.DES_ART end DOM_1,
|
||||
case when giorno = 1 then t.DES_ART end DOM_2,
|
||||
case when giorno = 2 then t.DES_ART end LUN,
|
||||
case when giorno = 3 then t.DES_ART end MAR,
|
||||
case when giorno = 4 then t.DES_ART end MER,
|
||||
case when giorno = 5 then t.DES_ART end GIO,
|
||||
case when giorno = 6 and rnk =1 then t.DES_ART else '1-' end VEN_1,
|
||||
case when giorno = 6 and rnk =2 then t.DES_ART else '2-' end VEN_2,
|
||||
case when giorno = 7 then t.DES_ART else '1-' end SAB_1,
|
||||
case when giorno = 7 then t.DES_ART else '2-' end SAB_2
|
||||
from t
|
||||
)
|
||||
select id, tipo_riepilogo,rnk, DES_TIPO,LUN, MAR, MER, GIO, VEN_1,VEN_2, SAB_1, SAB_2, DOM_1, DOM_2
|
||||
from t_des
|
||||
```
|
||||
Reference in New Issue
Block a user