IF OBJECT_ID('dbo.vw_fco_muni_tra') IS NOT NULL
    DROP VIEW dbo.vw_fco_muni_tra
GO
CREATE VIEW dbo.vw_fco_muni_tra
AS
SELECT compania, trabajador, dpto_tra = LEFT(dato, 2), muni_tra = SubString(dato, 4, 3)
FROM rel_trab_agr a
WHERE agrupacion = (SELECT x.dato FROM vw_fdt_parametros x
                    WHERE x.pais = 'COL' AND x.compania = a.compania
                      AND x.parametro = 'autoliq' AND x.secuencia = 44)
GO
GRANT SELECT ON dbo.vw_fco_muni_tra TO PUBLIC
GO
