﻿--select * from FLRPT_Produzione
--select count(*) from FLRPT_Produzione
CREATE VIEW [dbo].[FLRPT_Produzione]
AS
SELECT DISTINCT 
                      C6.Rete, C6.Cod_Fiscale AS CODFISCALE, C6.Cod_Agente AS CodAgente, NULL AS CodMan, C6.Freq_Monitoraggio AS FrequenzaReport, 
                      C6.Freq_Diagnosi AS freqstampadiagnosi
FROM
c6martperiodico.rp_vcontrattipergenerazionereport c6
--V (Marianna, Serena) NON FUNZIONA CON LA DATA A MANO
--
--FROM         C6Mart.CONTRATTOSEI AS C6 INNER JOIN
--                      C6Mart.GESTIONE_PDF_FTP AS PDF ON C6.Cod_Fiscale = PDF.CodiceFiscale
--WHERE     (C6.InvioBenvenuto = 'S') AND (C6.Data_FineAvanzato IS NULL OR
--                      C6.Data_FineAvanzato > '2010-06-30') AND (PDF.DataGenerazione < CAST(YEAR(GETDATE()) AS varchar) + '-' + CAST(MONTH(GETDATE()) AS varchar) 
--                      + '-' + '01')