1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| select f.cod_drg AS DRG, f.drg_cod_mdc AS MDC, f.drg_tipo AS Tipo, round(max(f.punti_medicare),4) as Peso_Mdc, f.drg_descr as Descrizione_DRG,
sum(f.TOT_ord) as Tot_Ord, sum(f.TOT_DH) as Tot_DH, sum(f.GG_Ord) as GG_Ord, sum(f.GG_DH) as GG_DH,
sum(f.Peso_ORD) as Peso_Ord, round((max(f.punti_medicare) * f.TOT_DH),2) as Peso_DH, sum(f.Importo_Ord) as Importo_Ord,
sum(f.Importo_DH) as Importo_DH, Desc_mese, codice, codice_rep
from (
select d.cod_drg, d.drg_cod_mdc, d.drg_tipo, if(cat_0 like 'ORD%',sum(d.punti_medicare),0) as punti_medicare, d.drg_descr,
if(cat_0 like 'ORD%',count(*), 0) as TOT_ord,
if(cat_0 not like 'ORD%',count(*), 0) as TOT_DH,
if(cat_0 like 'ORD%',sum(d.giorni),0) as GG_Ord,
if(cat_0 not like 'ORD%',sum(d.giorni),0) as GG_DH,
if(cat_0 like 'ORD%',round((count(*)*(d.punti_medicare)),2),0) as Peso_ORD,
if(cat_0 not like 'ORD%',round((count(*)*(d.punti_medicare)),2),0) as Peso_DH,
if(cat_0 like 'ORD%',round(sum(d.importo),2),0) as Importo_Ord,
if(cat_0 not like 'ORD%',round(sum(d.importo),2),0) as Importo_DH,
m.Descrizione as Desc_mese, d.cdc as codice, d.rep_dim as codice_rep
from dettaglio_sdo d
join tabelle_comuni.elenco_mesi m on m.indice=5
where d.anno=2008 and d.mese<=5 and "31463S100;31443S43C;21443S432;21433S130;21433S105;21433S092;11413S095;91199JA00;31463S09C;21447S58B;21434S58B;21433S120;21433S100;11413S100;11413S091;31463S130;31463S093;21443S43B;21434S582;21433S110;21433S09B;11413S09A;114135130"
like concat("%", cdc, "%") |
Partager