Les tengo la siguiente consulta, agardezco cualquier información al respecto.
Trabajo sobre MS SQLSERVER 2000 y estoy tirando una consulta declarando variables por el analizador de consultas y corre sin ningun problema. Ahora necesito dejar este script como una vista (view) ¿Es posible?.
Adjunto el script
Código:
como puedo hacerlo??Declare @fecha03 datetime Declare @fecha36 datetime Declare @fecha612 datetime Declare @fecha12 datetime Set @fecha03=convert(datetime,DATEADD(month,-3, getdate()),105) Set @fecha36=convert(datetime,DATEADD(month,-3, @fecha03 ),105) Set @fecha612=convert(datetime,DATEADD(month,-6, @fecha36),105) Set @fecha12=convert(datetime,DATEADD(month,-12, @fecha612),105) select "Costo Inmobilizados 0-3 meses"=sum(costo) from v_inmobilizados where fuv between @fecha03 and getdate() group by ano, mes UNION ALL select "Costo Inmobilizados 3-6 meses"=sum(costo) from v_inmobilizados where fuv between @fecha36 and @fecha03 group by ano, mes UNION ALL select "Costo Inmobilizados 6-12 meses"=sum(costo) from v_inmobilizados where fuv between @fecha612 and @fecha36 group by ano, mes UNION ALL select "Costo Inmobilizados Mas 12 meses"=sum(costo) from v_inmobilizados where fuv between '01-06-1998' and @fecha612 and fuc between '01-06-1998' and @fecha612 group by ano, mes
Gracias nuevamente