IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[V_EST_ARV_MD_F_GRP_PARAM_CURVA]'))
    DROP VIEW [dbo].[V_EST_ARV_MD_F_GRP_PARAM_CURVA]	  
GO

GO
--select * from V_EST_ARV_MD_F_GRP_PARAM_CURVA where cd_emp=1 and cd_filial = 2
CREATE VIEW [dbo].[V_EST_ARV_MD_F_GRP_PARAM_CURVA]
as
SELECT  
    c.CD_EMP	
    ,f.CD_FILIAL
    ,c.CD_SIGLA	
    ,CASE WHEN c.CD_SIGLA	=5 THEN 'AA'
	   WHEN c.CD_SIGLA	=1 THEN 'A'
	   WHEN c.CD_SIGLA	=2 THEN 'B'
	   WHEN c.CD_SIGLA	=3 THEN 'C'
	   WHEN c.CD_SIGLA	=4 THEN 'D'
	   END AS DS_SIGLA 
	   
    ,c.CD_ARV_PARAM	
    ,c.DS_ARV_PARAM
    ,l.CD_ARV_MERC_LINHA	
    ,c.VLR_PARAMETRO
	   	 
FROM 
    EST_ARV_MD_F_GRP_PARAM_CURVA C
    JOIN EST_ARV_MD_F_GRP_PARAM_CURVA_PRC_FILIAL F ON
    c.CD_EMP	=F.CD_EMP AND	
    c.CD_ARV_PARAM	=F.CD_ARV_PARAM	
    JOIN EST_ARV_MD_F_GRP_PARAM_CURVA_EST_ARV_MERC_LINHA  L ON
    c.CD_EMP	=L.CD_EMP AND	
    c.CD_ARV_PARAM	=L.CD_ARV_PARAM	
	   
	    