SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW [dbo].[vw_pr_products_variables_last_sit]
AS
	SELECT	v.*
	FROM	pr_products_variables v
			INNER JOIN	(
						SELECT	prdv_product_code, prdv_variable_code, max_date = MAX(prdv_variable_date_setup)
						FROM	pr_products_variables
						GROUP BY prdv_product_code, prdv_variable_code
						) as t	on	t.prdv_product_code = v.prdv_product_code
								and	t.prdv_variable_code = v.prdv_variable_code
								and	t.max_date = v.prdv_variable_date_setup
								
GO
