-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE procedure [C6Mart].[PL_S27ALtroPatrimonio] 
	-- Add the parameters for the stored procedure here
	@Rete char(1), 
	@CodiceFiscale varchar(16)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	SELECT 
		PATRIMONIO_ALTRO.DESCRIZIONE AS Denominazione,
		PATRIMONIO_ALTRO.QUANTITA AS NumeroQuote,
		PATRIMONIO_ALTRO.CTV AS Valore,
		SUM(PATRIMONIO_ALTRO.CTV) OVER (PARTITION BY 'Totale') as Totale
	FROM C6MART.PATRIMONIO_ALTRO 
	WHERE PATRIMONIO_ALTRO.RETE = @Rete
		AND PATRIMONIO_ALTRO.COD_FISCALE = @CodiceFiscale
	ORDER BY PATRIMONIO_ALTRO.CTV DESC
END