SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE view [dbo].[vw_ris_risks_situations_totals]
as

	SELECT	riss_risk_situation_id = rv.risv_risk_situation_id,
			riss_ann_tf = SUM(risv_tf),
			riss_ann_taxes = SUM(rv.risv_taxes),
			riss_ann_ti = SUM(rv.risv_ti)
	FROM ris_risks_situations rrs  
		LEFT JOIN ris_variables rv ON rrs.riss_risk_situation_id = rv.risv_risk_situation_id
	GROUP by rv.risv_risk_situation_id

	-- select * from vw_ris_risks_situations_totals

GO
