IF OBJECT_ID('dbo.vw_fco_hist_traslados_eps') IS NOT NULL
    DROP VIEW dbo.vw_fco_hist_traslados_eps
GO
CREATE VIEW dbo.vw_fco_hist_traslados_eps
AS
SELECT compania, trabajador, dato, fecha_alta
FROM hist_agrupaciones h
WHERE agrupacion = 
    ISNULL((SELECT dato FROM vw_fdt_parametros x
     WHERE pais = 'COL' AND x.compania = h.compania
       AND x.parametro = 'autoliq' AND x.secuencia = 21), 'EPS')
GO
GRANT ALL ON vw_fco_hist_traslados_eps TO PUBLIC
GO
