Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---=====================================================================================
- --==
- --== Memoria resumen facturado 2017
- --==
- --======================================================================================
- drop view vistaFacturado2017
- create view vistaFacturado2017 as
- select '201701' as Mes,Farmacia,case when ORGANISMO='01' and Entrega=0 then 'RElectronica' else 'RPapel' end as TipoRECETA,Organismo,COUNT(*) as Recetas , SUM(unidades) as Unidades , SUM(precio)as Precio,SUM(aportacion) as Aportacion , SUM(descuento) as RD82010 from RECETA18012017 group by Farmacia,organismo,entrega union all
- select '201702' as Mes,Farmacia,case when ORGANISMO='01' and Entrega=0 then 'RElectronica' else 'RPapel' end as TipoRECETA,Organismo,COUNT(*) as Recetas , SUM(unidades) as Unidades , SUM(precio)as Precio,SUM(aportacion) as Aportacion , SUM(descuento) as RD82010 from RECETA18022017 group by Farmacia,organismo,entrega union all
- select '201703' as Mes,Farmacia,case when ORGANISMO='01' and Entrega=0 then 'RElectronica' else 'RPapel' end as TipoRECETA,Organismo,COUNT(*) as Recetas , SUM(unidades) as Unidades , SUM(precio)as Precio,SUM(aportacion) as Aportacion , SUM(descuento) as RD82010 from RECETA18032017 group by Farmacia,organismo,entrega union all
- select '201704' as Mes,Farmacia,case when ORGANISMO='01' and Entrega=0 then 'RElectronica' else 'RPapel' end as TipoRECETA,Organismo,COUNT(*) as Recetas , SUM(unidades) as Unidades , SUM(precio)as Precio,SUM(aportacion) as Aportacion , SUM(descuento) as RD82010 from RECETA18042017 group by Farmacia,organismo,entrega union all
- select '201705' as Mes,Farmacia,case when ORGANISMO='01' and Entrega=0 then 'RElectronica' else 'RPapel' end as TipoRECETA,Organismo,COUNT(*) as Recetas , SUM(unidades) as Unidades , SUM(precio)as Precio,SUM(aportacion) as Aportacion , SUM(descuento) as RD82010 from RECETA18052017 group by Farmacia,organismo,entrega union all
- select '201706' as Mes,Farmacia,case when ORGANISMO='01' and Entrega=0 then 'RElectronica' else 'RPapel' end as TipoRECETA,Organismo,COUNT(*) as Recetas , SUM(unidades) as Unidades , SUM(precio)as Precio,SUM(aportacion) as Aportacion , SUM(descuento) as RD82010 from RECETA18062017 group by Farmacia,organismo,entrega union all
- select '201707' as Mes,Farmacia,case when ORGANISMO='01' and Entrega=0 then 'RElectronica' else 'RPapel' end as TipoRECETA,Organismo,COUNT(*) as Recetas , SUM(unidades) as Unidades , SUM(precio)as Precio,SUM(aportacion) as Aportacion , SUM(descuento) as RD82010 from RECETA18072017 group by Farmacia,organismo,entrega union all
- select '201708' as Mes,Farmacia,case when ORGANISMO='01' and Entrega=0 then 'RElectronica' else 'RPapel' end as TipoRECETA,Organismo,COUNT(*) as Recetas , SUM(unidades) as Unidades , SUM(precio)as Precio,SUM(aportacion) as Aportacion , SUM(descuento) as RD82010 from RECETA18082017 group by Farmacia,organismo,entrega union all
- select '201709' as Mes,Farmacia,case when ORGANISMO='01' and Entrega=0 then 'RElectronica' else 'RPapel' end as TipoRECETA,Organismo,COUNT(*) as Recetas , SUM(unidades) as Unidades , SUM(precio)as Precio,SUM(aportacion) as Aportacion , SUM(descuento) as RD82010 from RECETA18092017 group by Farmacia,organismo,entrega union all
- select '201710' as Mes,Farmacia,case when ORGANISMO='01' and Entrega=0 then 'RElectronica' else 'RPapel' end as TipoRECETA,Organismo,COUNT(*) as Recetas , SUM(unidades) as Unidades , SUM(precio)as Precio,SUM(aportacion) as Aportacion , SUM(descuento) as RD82010 from RECETA18102017 group by Farmacia,organismo,entrega union all
- select '201711' as Mes,Farmacia,case when ORGANISMO='01' and Entrega=0 then 'RElectronica' else 'RPapel' end as TipoRECETA,Organismo,COUNT(*) as Recetas , SUM(unidades) as Unidades , SUM(precio)as Precio,SUM(aportacion) as Aportacion , SUM(descuento) as RD82010 from RECETA18112017 group by Farmacia,organismo,entrega union all
- select '201712' as Mes,Farmacia,case when ORGANISMO='01' and Entrega=0 then 'RElectronica' else 'RPapel' end as TipoRECETA,Organismo,COUNT(*) as Recetas , SUM(unidades) as Unidades , SUM(precio)as Precio,SUM(aportacion) as Aportacion , SUM(descuento) as RD82010 from RECETA18122017 group by Farmacia,organismo,entrega
- drop table ResumenFacturado2017
- select * into ResumenFacturado2017 from vistaFacturado2017
- select * from ResumenFacturado2017 order by Mes,farmacia
- drop view VistFarmaIndustria2017
- create view VistFarmaIndustria2017 as
- select '201701' as Mes,farmacia,SUM([DescuentoPVL7.5]+[DescuentoPVL15]+[DescuentoPVL4.0]) as DescuentoPVL from Rdl82010Desglose18012017 where Situacion like 'ADHERIDO' group by Farmacia union all
- select '201702' as Mes,farmacia,SUM([DescuentoPVL7.5]+[DescuentoPVL15]+[DescuentoPVL4.0]) as DescuentoPVL from Rdl82010Desglose18022017 where Situacion like 'ADHERIDO' group by Farmacia union all
- select '201703' as Mes,farmacia,SUM([DescuentoPVL7.5]+[DescuentoPVL15]+[DescuentoPVL4.0]) as DescuentoPVL from Rdl82010Desglose18032017 where Situacion like 'ADHERIDO' group by Farmacia union all
- select '201704' as Mes,farmacia,SUM([DescuentoPVL7.5]+[DescuentoPVL15]+[DescuentoPVL4.0]) as DescuentoPVL from Rdl82010Desglose18042017 where Situacion like 'ADHERIDO' group by Farmacia union all
- select '201705' as Mes,farmacia,SUM([DescuentoPVL7.5]+[DescuentoPVL15]+[DescuentoPVL4.0]) as DescuentoPVL from Rdl82010Desglose18052017 where Situacion like 'ADHERIDO' group by Farmacia union all
- select '201706' as Mes,farmacia,SUM([DescuentoPVL7.5]+[DescuentoPVL15]+[DescuentoPVL4.0]) as DescuentoPVL from Rdl82010Desglose18062017 where Situacion like 'ADHERIDO' group by Farmacia union all
- select '201707' as Mes,farmacia,SUM([DescuentoPVL7.5]+[DescuentoPVL15]+[DescuentoPVL4.0]) as DescuentoPVL from Rdl82010Desglose18072017 where Situacion like 'ADHERIDO' group by Farmacia union all
- select '201708' as Mes,farmacia,SUM([DescuentoPVL7.5]+[DescuentoPVL15]+[DescuentoPVL4.0]) as DescuentoPVL from Rdl82010Desglose18082017 where Situacion like 'ADHERIDO' group by Farmacia union all
- select '201709' as Mes,farmacia,SUM([DescuentoPVL7.5]+[DescuentoPVL15]+[DescuentoPVL4.0]) as DescuentoPVL from Rdl82010Desglose18092017 where Situacion like 'ADHERIDO' group by Farmacia union all
- select '201710' as Mes,farmacia,SUM([DescuentoPVL7.5]+[DescuentoPVL15]+[DescuentoPVL4.0]) as DescuentoPVL from Rdl82010Desglose18102017 where Situacion like 'ADHERIDO' group by Farmacia union all
- select '201711' as Mes,farmacia,SUM([DescuentoPVL7.5]+[DescuentoPVL15]+[DescuentoPVL4.0]) as DescuentoPVL from Rdl82010Desglose18112017 where Situacion like 'ADHERIDO' group by Farmacia union all
- select '201712' as Mes,farmacia,SUM([DescuentoPVL7.5]+[DescuentoPVL15]+[DescuentoPVL4.0]) as DescuentoPVL from Rdl82010Desglose18122017 where Situacion like 'ADHERIDO' group by Farmacia
- select * into ResumenFarmaindustria2017 from VistFarmaIndustria2017
- select * from ResumenFarmaindustria2017
- drop view vistaRD119320112017
- create view vistaRD119320112017 as
- select '201701' as mes,* from recetaRD1193201118012017 union all
- select '201702' as mes,* from recetaRD1193201118022017 union all
- select '201703' as mes,* from recetaRD1193201118032017 union all
- select '201704' as mes,* from recetaRD1193201118042017 union all
- select '201705' as mes,* from recetaRD1193201118052017 union all
- select '201706' as mes,* from recetaRD1193201118062017 union all
- select '201707' as mes,* from recetaRD1193201118072017 union all
- select '201708' as mes,* from recetaRD1193201118082017 union all
- select '201709' as mes,* from recetaRD1193201118092017 union all
- select '201710' as mes,* from recetaRD1193201118102017 union all
- select '201711' as mes,* from recetaRD1193201118112017 union all
- select '201712' as mes,* from recetaRD1193201118122017
- select * into ResumenRD119320112017 from vistaRD119320112017
- select * from sysobjects where xtype like 'U' and name like 'Notifica%'
- select * from Notificados012017
- create view vistaNotificados2017 as
- select '201701' as mes, * from Notificados012017 union all
- select '201702' as mes, * from Notificados022017 union all
- select '201703' as mes, * from Notificados032017 union all
- select '201704' as mes, * from Notificados042017 union all
- select '201705' as mes, * from Notificados052017 union all
- select '201706' as mes, * from Notificados062017 union all
- select '201707' as mes, * from Notificados072017 union all
- select '201708' as mes, * from Notificados082017 union all
- select '201709' as mes, * from Notificados092017 union all
- select '201710' as mes, * from Notificados102017 union all
- select '201711' as mes, * from Notificados112017 union all
- select '201712' as mes, * from Notificados122017
- drop table ResumenNotificados2017
- select * into resumenNotificados2017 from vistaNotificados2017
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement