SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE view [dbo].[vw_acc_bordereaux_variables_totals]
as
	select	bdrvt_bordereau_id = bdrv_bordereau_id,
			bdrvt_variable_code = prdv_variable_code, 
			bdrvt_tf = sum(bdrv_tf),
			bdrvt_taxes = sum(bdrv_taxes),                              
			bdrvt_taxes_broker = sum(bdrv_taxes_broker),                              
			bdrvt_ti = sum(bdrv_ti),
			bdrvt_comm = sum(bdrv_comm),
			bdrvt_comm_taxes = sum(bdrv_comm_taxes),
			bdrvt_comm_taxes_broker = sum(bdrv_comm_taxes_broker)
	from	acc_bordereaux_variables bv
			inner join pr_products_variables pv on pv.prdv_variable_id = bv.bdrv_variable_id 
	group by bdrv_bordereau_id, prdv_variable_code
GO
